If the data is too large to be assigned directly to a CLOB variable, then we can read and write to the CLOB variable in stages using the DBMS_LOB.read and DBMS_LOB.write methods. But at this point we should cache CLOB variables, as shown in the first sentence below. Here is an example program that can not only write big data but also read it by switching the order DBMS_LOB.read and DBMS_LOB.write.
dbms_lob.createtemporary(lob_loc => x_clob,
cache => TRUE);
PROCEDURE load_clob(p_clob_in IN CLOB,
x_clob IN OUT NOCOPY CLOB) IS
l_clob_len NUMBER := dbms_lob.getlength(p_clob_in);
l_data VARCHAR2(32756);
l_buf_len_std NUMBER := 4000;
l_buf_len_cur NUMBER;
l_seg_count NUMBER;
l_write_offset NUMBER;
BEGIN
IF p_clob_in IS NOT NULL THEN
l_seg_count := floor(l_clob_len/l_buf_len_std);
FOR i IN 0 .. l_seg_count
LOOP
IF i = l_seg_count THEN
l_buf_len_cur := l_clob_len - i * l_buf_len_std;
ELSE
l_buf_len_cur := l_buf_len_std;
END IF;
IF l_buf_len_cur > 0 THEN
dbms_lob.read(lob_loc => p_clob_in,
amount => l_buf_len_cur,
offset => i * l_buf_len_std + 1,
buffer => l_data);
l_write_offset := nvl(dbms_lob.getlength(lob_loc => x_clob),
0) + 1;
dbms_lob.write(lob_loc => x_clob,
amount => l_buf_len_cur,
offset => l_write_offset,
buffer => l_data);
END IF;
END LOOP;
END IF;
END load_clob;
Reproduced in: https://blog.51cto.com/snans/1353672
Read More:
- Solution to the incomplete display of big data files printed by pychar
- Failed to create Oracle Oracle home user solution appears in oracle12c installation
- Ambari shield big data components
- How to Solve MacOS Big Sur MySQL workbench flashback problem
- How to Fix Sklearn ValueError: This solver needs samples of at least 2 classes in the data, but the data
- Oracle Data Guard Ping [arc2]: heartbeat failed to connect to standby “. Error is 12514 fault analysis
- Keras saves save() and save in the model_ weights()
- How to make eclipse after the program is modified, click run to automatically save it.
- How do I download or save a YouTube video to my computer?
- How to Fix “Oracle sp2-0640 unable to connect” Error
- IDEA报Unable to save settings: Failed to save settings. Please restart IntelliJ IDEA
- [Solved] SpringBoot Integrating Oracle reports errors: ORA-12504, TNS:listener was not given the SID in CONNECT_DATA
- Oracle database file is damaged, Error:ORA-01033 :ORACLE initialization or shutdown in progress
- The registered version of ArcEngine can edit the data in SDE (How to Fix 0x80040356 Error)
- UE4 cannot save the asset. The asset uasset failed to save
- Configure eslint in vscode to automatically repair and save the code
- Oracle data file space release
- How to Solve mybatis returns null when querying Oracle database with char type field
- Web Crawler: How to get the data in the web page and disguise the header, disguise as a browser to visit many times, avoid a single visit leading to IP blocked
- How to Fix Parser rerror: error tokenizing data. C error: expected 2 fields in line 53, saw 3