Can someone tell me what I'm doing wrong in the code below. It creates an output file of size 8192 every time and just cuts off before completing the output. While stepping through the code I'm showing the size of the CLOB passed in is 13888 so I'm not sure what's going on.
PROCEDURE p_xmlout (pi_dir IN VARCHAR2,
pi_file IN VARCHAR2,
pi_clob IN CLOB)
AS
l_output UTL_FILE.file_type;
l_amt NUMBER DEFAULT 32000;
l_pos NUMBER DEFAULT 1;
l_length NUMBER DEFAULT NVL(DBMS_LOB.getlength (pi_clob), 0);
BEGIN
IF l_length < 32760
THEN
l_output :=
UTL_FILE.fopen (pi_dir,
pi_file,
'w',
32767);
UTL_FILE.put (l_output, DBMS_LOB.SUBSTR (pi_clob, 32767, 1));
UTL_FILE.fflush (l_output);
UTL_FILE.fclose (l_output);
ELSE
l_output :=
UTL_FILE.fopen (pi_dir,
pi_file,
'w',
32767);
WHILE (l_pos < l_length)
LOOP
UTL_FILE.put (l_output, DBMS_LOB.SUBSTR (pi_clob, l_amt, l_pos));
UTL_FILE.fflush (l_output);
l_pos := l_pos + l_amt;
END LOOP;
UTL_FILE.new_line (l_output);
UTL_FILE.fclose (l_output);
END IF;
END p_xmlout;
Edited by: 820916 on Oct 11, 2011 2:26 PM
Edited by: 820916 on Oct 11, 2011 2:27 PM
Edited by: 820916 on Oct 11, 2011 2:28 PM
Edited by: 820916 on Oct 11, 2011 2:29 PM