Clob output to file
1. Loop reading, but cannot exceed 32 K (this is the limit of utl_file.put, rather than dbms_lob.read ).
-- Amount binary_integer: = 1;
-- Data_buffer varchar2 (1 );
Length_count: = dbms_lob.getlength (temp_blob );
While length_count> 0 Loop
Dbms_lob.read (temp_blob, amount, position, data_buffer );
Utl_file.put (filehandle, data_buffer );
Position: = Position + 1;
Length_count: = length_count-1;
Data_buffer: = NULL;
End loop;
2. Search read-out, but the two cannot exceed 32 K, that is, a row cannot exceed the capacity of 32 K or data_buffer.
-- Amount binary_integer;
-- Data_buffer varchar2 (4000 );
-- Pattern varchar2 (1 );
Pattern: = CHR (10 );
Amount: = dbms_lob.instr (temp_blob, pattern, 1, 1)-1;
While amount> 0 Loop
Dbms_lob.read (temp_blob, amount, position, data_buffer );
Utl_file.put_line (filehandle, data_buffer );
Position: = dbms_lob.instr (temp_blob, pattern, position, 1) + 1;
Amount: = dbms_lob.instr (temp_blob, pattern, position, 1)-position;
Data_buffer: = NULL;
End loop;
Dbms_lob.substr is not recommended for LOB operations, because there is a limit of 32 K.