When I try to use DBMS_LOB.convertToBlob procedure multiple times in the same PLSQL block only the first execution works as expected. All additional executions produce empty blobs. Here is an example:
DECLARE
v_temp1 varchar2(32767) := 'absd';
V_temp1_blob BLOB;
V_temp2 varchar2(32767) := 'efghi';
V_temp2_blob BLOB;
v_in integer := 1;
v_out integer := 1;
v_lang integer := 0;
v_warning integer := 0;
BEGIN
DBMS_LOB.createTemporary (V_temp1_blob, TRUE);
DBMS_LOB.convertToBlob(V_temp1_blob, V_temp1, DBMS_LOB.LOBMAXSIZE, v_in, v_out, DBMS_LOB.DEFAULT_CSID, v_lang, v_warning);
dbms_output.put_line('V_temp1_blob: ' || dbms_lob.getlength(V_temp1_blob));
DBMS_LOB.createTemporary (V_temp2_blob, TRUE);
DBMS_LOB.convertToBlob(V_temp2_blob, V_temp2, DBMS_LOB.LOBMAXSIZE, v_in, v_out, DBMS_LOB.DEFAULT_CSID, v_lang, v_warning);
dbms_output.put_line('V_temp2_blob: ' || dbms_lob.getlength(V_temp2_blob));
END;
OUTPUT:
V_temp1_blob: 4
V_temp2_blob: 0
My expected output is:
V_temp1_blob: 4
V_temp2_blob: 5
What am I missing here ?