Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <code>long</code> datatype is deprecated; if you can you should seriously consider <a href="http://docs.oracle.com/cd/E11882_01/server.112/e10592/sql_elements001.htm#i45885" rel="nofollow">migrating your <code>long</code> column to a <code>clob</code></a>.</p> <p>If you were working with a <code>clob</code> you could append past the 32k <code>varchar2</code> limit like this:</p> <pre><code>declare l_clob clob; begin dbms_lob.createtemporary(l_clob, true); dbms_lob.open(l_clob, dbms_lob.lob_readwrite); dbms_lob.writeappend(l_clob, 4, '1234'); for i in 1..10000 loop dbms_lob.writeappend(l_clob, 5, '.5678'); end loop; dbms_output.put_line('CLOB length: ' || length(l_clob)); dbms_lob.close(l_clob); dbms_lob.freetemporary(l_clob); end; / CLOB length: 50004 </code></pre> <p>You can append to a <code>long</code> with the concatenate operator <code>||</code>, but as you've seen already, only up to 32k. There is no easy way to handle <code>long</code> values above that within PL/SQL. You might be able to do soemthing with <code>dbms_sql</code> but it's really not going to be worth the effort if there is any possiblility of switching the table column to a <code>clob</code>.</p> <hr> <p>If you want to pass the clob back to the caller, and it's a temporary clob, it will have to be defined by the caller and be passed it after it's created:</p> <pre><code>create or replace procedure proc1 as l_clob clob; begin dbms_lob.createtemporary(l_clob, true); proc2(l_clob); dbms_output.put_line('proc1 CLOB length: ' || length(l_clob)); dbms_lob.freetemporary(l_clob); end; / create or replace procedure proc2(p_clob in out clob) as begin dbms_lob.open(p_clob, dbms_lob.lob_readwrite); dbms_lob.writeappend(p_clob, 5, '12345'); for i in 1..9999 loop dbms_lob.writeappend(p_clob, 5, '.56789'); end loop; dbms_output.put_line('proc2 CLOB length: ' || length(p_clob)); dbms_lob.close(p_clob); end; / exec procs; proc2 CLOB length: 50000 proc1 CLOB length: 50000 </code></pre> <p>Otherwise the object won't exist as far as the caller is concerned.</p> <p>If the <code>clob</code> exists - selected from a table, say, so you don't need the <code>createtemporary</code> call - then you can just assign it to an <code>out</code> parameter, but I don't think that's the case for what you've described.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload