[Oracle] clob output to file

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.