Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Store > 32K in a CLOB variable

partlycloudyMay 28 2015 — edited May 28 2015

Oracle 11.1

CREATE OR REPLACE PROCEDURE foo(p_input IN clob,p_output OUT INTEGER)

IS

BEGIN

    WITH data AS (

        SELECT xmltype(p_input) xml

        FROM dual

    )

    SELECT

        length(extractValue(d.xml,'//value'))

    INTO p_output

    FROM data d;

END;

/

The incoming XML content passed into FOO may be larger than 32K so I just want to make sure Oracle can handle it but I am just not able to setup a simple test case. I googled, looked up old threads from OTN and AskTom but no matter what I do I run into either ORA-01706: user function result value was too large or ORA-06502: PL/SQL: numeric or value error: character string buffer too small

OK so extractValue returns a VARCHAR2 so it can't handle larger than 4000 but so I tried to use extract(d.dml,'//value').getclobval but that wouldn't compile with PL/SQL: ORA-22806: not an object or REF.  Clearly, I am missing some concepts here.

DECLARE

    l_clob clob;

    l_open clob := '<node><value>';

    l_close clob := '</value></node>';

    l_output INTEGER;

BEGIN

     DBMS_LOB.createtemporary(l_clob,TRUE);

     dbms_lob.writeappend(l_clob,length(l_open),l_open);

        for i in 1..10 loop

          dbms_lob.writeAppend( l_clob, 32000, rpad('*',32000,'*') );

        end loop;

     dbms_lob.writeappend(l_clob,length(l_CLOSE),l_CLOSE);

    foo(l_clob,l_output);

    dbms_output.put_line('Output='||l_output);

END;

/

Or just simply l_clob := l_open||rpad('*',32000,'*')||l_close

What am I missing? I just want to prove to myself that I can successfully pass in a XML document larger than 32K and use XMLTYPE methods to process the data in a relational format.

Thanks

This post has been answered by BluShadow on May 28 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 25 2015
Added on May 28 2015
12 comments
1,957 views