passing variable of size greater than 32767 from Pro*C to PL/SQL procedure [message #483106] |
Thu, 18 November 2010 08:00 |
vikrant_jain
Messages: 1 Registered: November 2010 Location: Chennai
|
Junior Member |
|
|
Hi,
I am trying to pass a variable os size greater than 32767 from Pro*C to an SQL procedure.I tried assigning the host variable directly to a CLOB in the SQL section but nothing happens.In the below code the size of l_var1 is 33000.PROC_DATA is a procedure that takes CLOB as input and gives the other three(Data,Err_Code,Err_Msg) as output.These variables are declared globally.
Process_Data(char* l_var1)
{
EXEC SQL EXECUTE
DECLARE
l_clob clob;
BEGIN
l_clob := :l_var1
PROC_DATA(l_clob,:Data,:Err_Code,:Err_Msg) ;
COMMIT;
END;
END-EXEC;
}
I also tried using DBMS_LOB.This was the code that i used.
Process_Data(char* l_var1)
{
EXEC SQL EXECUTE
DECLARE
l_clob clob;
BEGIN
DBMS_LOB.CREATETEMPORARY(l_clob,TRUE);
DBMS_LOB.OPEN(l_clob,dbms_lob.lob_readwrite);
DBMS_LOB.WRITE (l_clob, LENGTH (:l_var1), 1,:l_var1);
PROC_DATA(l_clob,:Data,:Err_Code,:Err_Msg) ;
COMMIT;
END;
END-EXEC;
}
Here since DBMS_LOB packages allow a maximum of 32767,the value of l_var1 is not being assigned to l_clob.
I am able to do the above process provided i split l_var1 into two variables and then append to l_clob using WRITEAPPEND.i.e l_var1 is 32000 in length and l_var2 contains the rest.
Process_Data(char* l_var1,char* l_var2)
{
EXEC SQL EXECUTE
DECLARE
l_clob clob;
BEGIN
dbms_lob.createtemporary(l_clob,TRUE);
dbms_lob.OPEN(l_clob,dbms_lob.lob_readwrite);
DBMS_LOB.WRITE (l_clob, LENGTH (:l_var1), 1,:l_var1);
DBMS_LOB.WRITEAPPEND (l_clob, LENGTH(:l_var2), :l_var2);
PROC_DATA(l_clob,:Data,:Err_Code,:Err_Msg) ;
COMMIT;
END;
END-EXEC;
}
But the above code requires dynamic memory allocation in Pro*C which i would like to avoid.Could you let me know if there is any other way to perform the above?
|
|
|