Append Clob

Hi!
I have a stored procedure that loops through a resultset and appends the CLOB variable. Below is the code. I have problem using DBMS_LOB.Append. When I execute the procedure, it gives an error (Could find LOB Locator).
Code start-
PROCEDURE ABC(p_ids IN VARCHAR2,p_result OUT CLOB ) AS
bcp_result CLOB :=EMPTY_CLOB();
bcp_result1 CLOB :=EMPTY_CLOB();
CURSOR prof_cursor IS (Select statement)
BEGIN
FOR r_prof_item IN prof_cursor LOOP
--App_Util.getchunk(21); returns a clob
bcp_result1 := App_Util.getchunk(21); DBMS_LOB.APPEND(bcp_result, bcp_result1);
END LOOP ;
Code End --
Vivek

Empty clobs have no locators. Try creating a temporary clob or appending to a clob locator selected from a table.
null

Similar Messages

  • Error while appending clob data type ....

    Hi,
    I'm trying to append a clob variable as below -
    declare
    temp_log clob;
    begin
    temp_log:=temp_log||'validated;errors in Legal Units: '||to_char(n1)||'/'||to_char(n2)||'Start '||to_char(beginrun,'HH:MI:SS')||'ended'||to_char(endrun,'HH:MI:SS')||chr(10);
    exception
    when others then
    dbms_output.put_line(sqlerrm);
    end;
    =>
    and got the error msg -
    ORA-06502: PL/SQL: numeric or value error
    ORA-00001: uni
    After that I try as below :-
    declare
    temp_log clob;
    begin
    dbms_lob.writeappend(temp_log,length(temp_log||'validated;errors in Legal Units: '||to_char(n1)||'/'||to_char(n2)||'Start '||to_char(beginrun,'HH:MI:SS')||'ended'||to_char(endrun,'HH:MI:SS')),temp_log||'validated;errors in Legal Units: '||to_char(n1)||'/'||to_char(n2)||'Start '||to_char(beginrun,'HH:MI:SS')||'ended'||to_char(endrun,'HH:MI:SS'));
    exception
    when others then
    dbms_output.put_line(sqlerrm);
    end;
    And got below error -
    ORA-06502: PL/SQL: numeric or value error: invalid LOB locator specified:
    ORA-22275
    ORA-06512: at "SYS.DBMS_LOB", line 833
    ORA-06512: at "EGR.TRANS_BVD_NEW", line 1290
    ORA-06502: PL/SQL: numeric or value error: invalid LOB locator specified:
    ORA-22275
    ORA-06512: at "SYS.DBMS_LOB", line 833
    pls help me....
    Subir

    it is a single line... but it is changing here due to less space....
    It is some thing like -
    temp_log:=temp_log||'treatments validated;errors in Legal Units: '||to_char(n1)||'/'||to_char(n2)||'Start '||to_char(beginrun,'HH:MI:SS')||'ended'||to_char(endrun,'HH:MI:SS')||chr(10);
    Subir

  • Combining clob taking too much time - need help

    Hello,
    I want to append clob values into another clob value like
    declare
    v_temp clob;
    v_c1_temp clob;
    cursor c1 as select clob_data from t;
    -- here t table contains clob_data column holding clob data
    -- t table have more then 1500 rows
    begin
    v_temp := '';
    open c1 into v_c1_temp;
    loop
    v_temp := v_temp + v_c1_temp; --------- combining clob (concat may be used)
    end loop;
    close(c1);
    end;
    above part also repeats in outer loop (not shown here)
    my problem is :- it is taking too much time - you dont believe 90% more time due to that concatenation.
    is it any smart way to do same thing?
    It will be very helpful to me.

    Hi ,
    You should also always try and have the latest BI content patch installed but I don't think this is the problem. It seems that there
    are alot of objects to collect. Under 'grouping' you can select the option 'only necessary objects', please check if you can
    use this option to  install the objects that you need from content.
    Best Regards,
    Des.

  • CLOB type give error in procedure

    I have 1 procedure with 3 argument,In this 1 argument is of type CLOB.
    When i call procedure then it give error Of character set problem.
    But when i remove the CLob argument the procedure executed successfuly.
    I am using this procedure in Oracle8i
    Why this happen? what to do to solve this?

    Hi,
    It is working for me in Oracle8i/ 9i. What exactly your procedure is doing?
    1 create or replace procedure test_clob(ch clob)
    2 is
    3 begin
    4 dbms_output.put_line(ch);
    5* end;
    SQL> /
    SQL> exec test_clob('mmmm');
    mmmm
    PL/SQL procedure successfully completed.
    is your procedure trying to APPEND clob into another clob?
    Thanks
    M Thiyagarajan

  • How to generate XML for following?

    Hello Everyone,
    I have following snippet of PLSQL code with for loops and record type arrays. Each loop can return separate number of rows and iterate that many times. For e.g. the for loop tab_rec may fetch 50 rows where as the for loop sql_rec may return 80 rows.
    I need to acoomodate all of these record arrays into a single xml file. Each for loop will repreesent one data set. Something like this.
    <dataset>
    <set value = tab_rec(kounter).tvalue >
    <set value = ?
    </dataset>
    Questions:
    1) How can I dynamically generate just one single XML file for all for loops metnioend below in this message?
    2) How can I dynamically generate tags for e.g. <set> tag above if I put XMLELEMENT() under a for loop kounter. To explain this in a better way consider pseudo code example below.
    for i in 1..kounter loop
    <dataset>
    <set value = tab_rec(i).tvalue >
    *<set value = *?*   -- How do i generate these <set> tags when tebrec(i).value will return many rows?*_
    </dataset>
    Thanks for reading this post. Again, the exmple for loops to generate one single XML file is given below.
    For loops in the issue are mentioned below
    FOR a IN tab_recc
    LOOP
    tab_rec (tab_kounter).tsegment := a.ebs_table;
    tab_rec (tab_kounter).tbytes := a.sizemb;
    tab_kounter := tab_kounter + 1;
    END LOOP;
    FOR b IN sql_recc
    LOOP
    sql_rec (sql_kounter).thash := b.hash_value;
    sql_rec (sql_kounter).texecution_read := b.reads_per_execution;
    sql_kounter := sql_kounter + 1;
    END LOOP;
    FOR c IN sess_recc
    LOOP
    sess_rec (session_kounter).tsid := c.SID;
    sess_rec (session_kounter).tvalue := c.VALUE;
    session_kounter := session_kounter + 1;
    END LOOP;
    FOR d IN user_recc
    LOOP
    user_rec (dbuser_kounter).tphysical_reads := d.physical_reads;
    user_rec (dbuser_kounter).tuser := d.username;
    dbuser_kounter := dbuser_kounter + 1;
    END LOOP;
    FOR e IN ebs_user
    LOOP
    ebs_rec (ebs_kounter).tuser := e.user_name;
    ebs_rec (ebs_kounter).ttime := e.rtime;
    ebs_kounter := ebs_kounter + 1;
    END LOOP;

    Sorry for delay in response.
    I have pasted the complete code that will show the relation ship between data and XML. What I am trying to do here is to prepare smal packets of XML through XML element and then roll it up to a final grand CLOB variable. and pass that through XML creation. I have used DBMS_JAVA package to append clobs.
    The issue now I am running into, it generates JUNK in xml. pure junk and nothing else Thanks R,
    FOR a IN tab_recc
    LOOP
    tab_rec (tab_kounter).tsegment := a.ebs_table;
    tab_rec (tab_kounter).tbytes := a.sizemb;
    tab_kounter := tab_kounter + 1;
    END LOOP;
    FOR b IN sql_recc
    LOOP
    sql_rec (sql_kounter).thash := b.hash_value;
    sql_rec (sql_kounter).texecution_read := b.reads_per_execution;
    sql_kounter := sql_kounter + 1;
    END LOOP;
    FOR c IN sess_recc
    LOOP
    sess_rec (session_kounter).tsid := c.SID;
    sess_rec (session_kounter).tvalue := c.VALUE;
    session_kounter := session_kounter + 1;
    END LOOP;
    FOR d IN user_recc
    LOOP
    user_rec (dbuser_kounter).tphysical_reads := d.physical_reads;
    user_rec (dbuser_kounter).tuser := d.username;
    dbuser_kounter := dbuser_kounter + 1;
    END LOOP;
    FOR e IN ebs_user
    LOOP
    ebs_rec (ebs_kounter).tuser := e.user_name;
    ebs_rec (ebs_kounter).ttime := e.rtime;
    ebs_kounter := ebs_kounter + 1;
    END LOOP;
    FOR aa IN 1 .. tab_kounter
    LOOP
    if aa = 1 then
    SELECT XMLELEMENT
    ("dataset",
    xmlattributes (v_top50id1 AS "Id"),
    XMLELEMENT ("set",
    xmlattributes (aa AS "Id",
    tab_rec (aa).tsegment AS "value"
    ).getclobval ()
    INTO tablob --clob type
    FROM DUAL;
    end if;
    END LOOP;
    FOR bb IN 1 .. sql_kounter
    LOOP
    if bb = 1 then
    SELECT XMLELEMENT
    ("dataset",
    xmlattributes (v_top50id2 AS "Id"),
    XMLELEMENT ("set",
    xmlattributes (bb AS "Id",
    sql_rec (bb).thash AS "value"
    ).getclobval ()
    INTO sqlob --clob type
    FROM DUAL;
    end if;
    END LOOP;
    FOR cc IN 1 .. session_kounter
    LOOP
    if cc= 1 then
    SELECT XMLELEMENT
    ("dataset",
    xmlattributes (v_top50id3 AS "Id"),
    XMLELEMENT ("set",
    xmlattributes (cc AS "Id",
    sess_rec (cc).tsid AS "value"
    ).getclobval ()
    INTO sesslob --clob type
    FROM DUAL;
    end if;
    END LOOP;
    FOR dd IN 1 .. dbuser_kounter
    LOOP
    if dd = 1 then
    SELECT XMLELEMENT
    ("dataset",
    xmlattributes (v_top50id4 AS "Id"),
    XMLELEMENT ("set",
    xmlattributes (dd AS "Id",
    user_rec (dd).tuser AS "value"
    ).getclobval ()
    INTO dbulob --clob type
    FROM DUAL;
    end if;
    END LOOP;
    FOR ee IN 1 .. ebs_kounter
    LOOP
    if ee = 1 then
    SELECT XMLELEMENT
    ("dataset",
    xmlattributes (v_top50id5 AS "Id"),
    XMLELEMENT ("set",
    xmlattributes (ee AS "Id",
    ebs_rec (ee).tuser AS "value"
    ).getclobval ()
    INTO ebslob --clob type
    FROM DUAL;
    end if;
    END LOOP;
    SELECT XMLELEMENT
    ("Chart",
    xmlattributes (v_caption AS "caption",
    v_subcaption AS "shownames",
    v_xaxisname AS "showvalues",
    v_yaxisname AS "decimals"
    XMLELEMENT ("categories",
    XMLELEMENT ("category",
    xmlattributes (v_label1 AS "label")
    XMLELEMENT ("category",
    xmlattributes (v_label2 AS "label")
    XMLELEMENT ("category",
    xmlattributes (v_label3 AS "label")
    XMLELEMENT ("category",
    xmlattributes (v_label4 AS "label")
    XMLELEMENT ("category",
    xmlattributes (v_label5 AS "label")
    XMLELEMENT ("category",
    xmlattributes (v_label6 AS "label")
    tablob, --clob type
    sqlob, --clob type
    sesslob, --clob type
    dbulob, --clob type
    ebslob --clob type
    ).getclobval ()
    INTO v_top50 --clob type
    FROM DUAL;
    DBMS_LOB.append (v_xmlmessage, v_top50); --both are clob type
    v_filename := 'Top50.xml';
    writexml (p_dir_path => v_dir_path,
    p_filename => v_filename,
    p_xml => v_xmlmessage
    );

  • Pl/sql or numeric value error

    Hi
    I'm trying to append CLOB to CLOB (assuming both are not null and lenght is less than the max allowed) and getting the error, Why is that error coming, the length cobined is only 50k.
    PK_UTILITIES.sp_get_recs(site_id_i, entity_id_i, false, v_clob_str);
    v_len := DBMS_LOB.getlength(v_clob_str);
    IF (NVL(v_len,0) > 0 ) THEN
    DBMS_OUTPUT.PUT_LINE('Length: '||v_len);
    DBMS_LOB.WRITEAPPEND(XML_o,length(v_clob_str),v_clob_str);
    END IF;
    Thanks in advance
    Murthy

    We are using the same DBMS_LOB.appendAs I said above, you must do a DBMS_LOB.CreateTemporary to create and populate a LOB correctly.
    SQL> declare
      2    lob CLOB ;
      3  begin
      4    for idx in 1 .. 100
      5    loop
      6      dbms_lob.writeappend(lob, 4000, RPAD('*', 4000, '*')) ;
      7    end loop ;
      8    dbms_output.put_line(dbms_lob.getlength(lob)) ;
      9  end ;
    10  /
    declare
    ERROR at line 1:
    ORA-06502: PL/SQL: numeric or value error: invalid LOB locator specified: ORA-22275
    ORA-06512: at "SYS.DBMS_LOB", line 789
    ORA-06512: at line 6
    SQL> declare
      2    lob CLOB ;
      3  begin
      4    lob := NULL ;
      5    for idx in 1 .. 100
      6    loop
      7      dbms_lob.writeappend(lob, 4000, RPAD('*', 4000, '*')) ;
      8    end loop ;
      9    dbms_output.put_line(dbms_lob.getlength(lob)) ;
    10  end ;
    11  /
    declare
    ERROR at line 1:
    ORA-06502: PL/SQL: numeric or value error: invalid LOB locator specified: ORA-22275
    ORA-06512: at "SYS.DBMS_LOB", line 789
    ORA-06512: at line 7
    SQL> declare
      2    lob CLOB ;
      3  begin
      4    dbms_lob.createtemporary(lob, TRUE) ;
      5    for idx in 1 .. 100
      6    loop
      7      dbms_lob.writeappend(lob, 4000, RPAD('*', 4000, '*')) ;
      8    end loop ;
      9    dbms_output.put_line(dbms_lob.getlength(lob)) ;
    10    dbms_lob.freetemporary(lob) ;
    11  end ;
    12  /
    400000
    PL/SQL procedure successfully completed.
    SQL>

  • Again..What elapse time you are expecting for this query..

    Hi Again want to confirm with you Oracle gurus ...
    Does following plsql code really takes time in mins
    I do not used to deal with clob data so can not say why there is so delay..
    -> TableA has 3000 rows with text_data clob column holding large clob data...
    -> TableB has some thing which i wnat to append in text_data column..
    -> Trying to minimize elapse time..
    declare
    cursor c1 is select object_id from TableA where object_type = 'STDTEXT' and rownum < 1000;
    TYPE v_object_id_t is table of TableA.object_id%type index by binary_integer;
    v_object_id v_object_id_t;
    cursor c2(p_object_id TableA.object_id%type) is
    select to_clob('<IMG "MFI_7579(@CONTROL=' || ref_id || ',REF_ID=' || ref_id || ').@UDV">' || substr('abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx',1, round(to_char(systimestamp,'FF2')/2)-1)) temp_data
    from TableB where object_id = p_object_id;
    TYPE v_text_data_t is table of TableA.text_data%type index by binary_integer;
    v_text_data v_text_data_t;
    v_temp clob ;
    r2 c2%rowtype;
    begin
    open c1;
    loop
    FETCH c1 BULK COLLECT INTO v_object_id ;
    for i in 1..v_object_id.count loop
    dbms_lob.createtemporary(v_temp,TRUE);
    open c2(v_object_id(i));
    loop
    fetch c2 into r2;
    exit when c2%NOTFOUND;
    dbms_lob.append(v_temp,r2.temp_data);
    end loop;
    close c2;
    v_text_data(i) := '';
    v_text_data(i) := v_temp;
    -- DBMS_OUTPUT.PUT_LINE (length(v_text_data(i)));
    dbms_lob.freetemporary(v_temp);
    end loop;
    forall counter in 1..v_text_data.count
    update TableA
    set text_data = concat(text_data,v_text_data(counter))
    where object_id = v_object_id(counter);
    DBMS_OUTPUT.PUT_LINE ('Update performed!');
    commit;
    EXIT WHEN c1%NOTFOUND;
    end loop;
    close c1;
    exception
    when others then
    DBMS_OUTPUT.PUT_LINE ('Update not performed!');
    end;
    -- Last elapse time 333 sec for 8k text_data data if i use 16k block size
    -- Last elapse time 1503 sec for 2k text_data data if i use 8k block size
    ->> Am I going rigth way???
    Please Help...
    Cheers :)
    Rushang Kansara
    Message was edited by:
    Rushang Kansara
    Message was edited by:
    Rushang Kansara

    Here is an example that shows SQL and PL/SQL methods. Note that the DBMS_LOB.WriteAppend() call is the wrong call to use (as I did above. The correct call to use (for appending CLOB to a CLOB) is DBMS_LOB.Append() (as shown below).
    SQL> create table my_docs
    2 (
    3 doc_id number,
    4 doc CLOB
    5 )
    6 /
    Table created.
    SQL>
    SQL> create sequence id
    2 start with 1
    3 increment by 1
    4 nomaxvalue
    5 /
    Sequence created.
    SQL>
    SQL>
    SQL> create or replace procedure AddXML( rowCount number DEFAULT 1000 ) is
    2 cursor curXML is
    3 select
    4 XMLElement( "ORA_OBJECT",
    5 XMLForest(
    6 object_id as "ID",
    7 owner as "OWNER",
    8 object_type as "TYPE",
    9 object_name as "NAME"
    10 )
    11 ) as "XML_DATA"
    12 from all_objects
    13 where rownum <= rowCount;
    14
    15 tmpClob CLOB;
    16 xml XMLType;
    17 lineCount number := 0;
    18 docID number;
    19 begin
    20 DBMS_LOB.CreateTemporary( tmpClob, TRUE );
    21
    22 open curXML;
    23 loop
    24 fetch curXML into xml;
    25 exit when curXML%NOTFOUND;
    26
    27 lineCount := lineCount + 1;
    28
    29 DBMS_LOB.Append(
    30 tmpClob,
    31 xml.GetCLOBVal() -- add the XML CLOB to our temp CLOB
    32 );
    33 end loop;
    34 close curXML;
    35
    36 insert
    37 into my_docs
    38 ( doc_id, doc )
    39 values
    40 ( id.NextVal, tmpClob )
    41 returning doc_id into docID;
    42
    43 commit;
    44
    45 DBMS_LOB.FreeTemporary( tmpClob );
    46 DBMS_OUTPUT.put_line( lineCount||' XML object(s) were appended to document '||docID );
    47 end;
    48 /
    Procedure created.
    SQL> show errors
    No errors.
    SQL>
    SQL> -- add 3 CLOBs of varying sizes
    SQL> exec AddXML
    1000 XML object(s) were appended to document 1
    PL/SQL procedure successfully completed.
    SQL> exec AddXML(100)
    100 XML object(s) were appended to document 2
    PL/SQL procedure successfully completed.
    SQL> exec AddXML(500)
    500 XML object(s) were appended to document 3
    PL/SQL procedure successfully completed.
    SQL>
    SQL> -- what are the sizes of the CLOBs and the total size?
    SQL> select
    2 doc_id,
    3 SUM( ROUND( LENGTH(doc)/1024 ) ) as "KB_SIZE"
    4 from my_docs
    5 group by
    6 ROLLUP(doc_id)
    7 /
    DOC_ID KB_SIZE
    1 98
    2 9
    3 47
    154
    SQL>
    SQL> -- add an empty CLOB
    SQL> insert into my_docs values( 0, NULL );
    1 row created.
    SQL> commit;
    Commit complete.
    SQL>
    SQL> -- note that the new CLOB is zero KB in size
    SQL> select
    2 doc_id,
    3 ROUND( LENGTH(doc)/1024 ) as "KB_SIZE"
    4 from my_docs
    5 /
    DOC_ID KB_SIZE
    1 98
    2 9
    3 47
    0
    SQL>
    SQL> -- we add document 1 to 3 to document 0 using SQL
    SQL> update my_docs
    2 set doc = doc || (select t.doc from my_docs t where t.doc_id = 1 )
    3 where doc_id = 0;
    1 row updated.
    SQL>
    SQL> update my_docs
    2 set doc = doc || (select t.doc from my_docs t where t.doc_id = 2 )
    3 where doc_id = 0;
    1 row updated.
    SQL>
    SQL>
    SQL> update my_docs
    2 set doc = doc || (select t.doc from my_docs t where t.doc_id = 3 )
    3 where doc_id = 0;
    1 row updated.
    SQL>
    SQL> commit;
    Commit complete.
    SQL>
    SQL> -- what are the sizes now?
    SQL> select
    2 doc_id,
    3 ROUND( LENGTH(doc)/1024 ) as "KB_SIZE"
    4 from my_docs
    5 /
    DOC_ID KB_SIZE
    1 98
    2 9
    3 47
    0 154
    SQL>
    SQL>
    SQL> -- we do the adds again, but time time using a PL/SQL procedure to do it
    SQL> declare
    2 cursor c is
    3 select doc from my_docs where doc_id in (1,2,3);
    4
    5 updateClob CLOB;
    6 appendClob CLOB;
    7 begin
    8 -- we must lock the row for update and then we can write directly
    9 -- to that row's CLOB locator (without using the UPDATE SQL statement)
    10 select
    11 doc into updateClob
    12 from my_docs
    13 where doc_id = 0
    14 for update;
    15
    16
    17 open c;
    18 loop
    19 fetch c into appendClob;
    20 exit when c%NOTFOUND;
    21
    22 -- we append the CLOBs to document 0
    23 DBMS_LOB.Append( updateClob, appendClob );
    24 end loop;
    25
    26 -- .. and commit the changes to document 0's CLOB locator
    27 commit;
    28 end;
    29 /
    PL/SQL procedure successfully completed.
    SQL>
    SQL>
    SQL> -- what are the sizes now?
    SQL> select
    2 doc_id,
    3 ROUND( LENGTH(doc)/1024 ) as "KB_SIZE"
    4 from my_docs
    5 /
    DOC_ID KB_SIZE
    1 98
    2 9
    3 47
    0 308
    SQL>

  • Clob datatype- very slow while appending

    Hi,
    please help on below pl/sql block.
    I have written below code, but the response time is very slow.
    the table - aux_comm_3_to_1 has more than 1 Lakh records.
    and I have append all the record and send the record as clob OUT parameter to GUI.
    Pls suggest me.
    declare
    TEMP_XML clob;
    XML_OW clob;
    begin
    FOR rec IN (SELECT
    FRAMEREFERENCEDATE,
    EU_LEU_ID_OWNER,
    EU_LEU_ID_SUBSIDIARY,
    DIRECT_PERCENT,
    QUALITY_IND_DIRECT_PERCENT,
    SOURCE_DIRECT_PERCENT,
    REF_DATE_DIRECT_PERCENT,
    KIND_OF_CONTROL,
    SOURCE_KIND_OF_CONTROL,
    REF_DATE_KIND_OF_CONTROL,
    DATE_OF_COMMENCEMENT,
    SOURCE_DATE_OF_COMMENCEMENT,
    REF_DATE_OF_COMMENCEMENT,
    DATE_OF_CESSATION,
    SOURCE_DATE_OF_CESSATION,
    REF_DATE_OF_CESSATION,
    SOURCE_TA_OWNERSHIP,
    REF_DATE_TA_OWNERSHIP
    FROM aux_comm_3_to_1 )
    LOOP
    TEMP_XML :=
    '<TARGET_OWNERSHIP="'
    || idcounter
    ||'"FRAMEREFERENCEDATE="'||rec.FRAMEREFERENCEDATE
    ||'"EU_LEU_ID_OWNER="'||rec.EU_LEU_ID_OWNER
    ||'"EU_LEU_ID_SUBSIDIARY="'||rec.EU_LEU_ID_SUBSIDIARY
    ||'"DIRECT_PERCENT="'||rec.DIRECT_PERCENT
    ||'"QUALITY_IND_DIRECT_PERCENT="'||rec.QUALITY_IND_DIRECT_PERCENT
    ||'"SOURCE_DIRECT_PERCENT="'||rec.SOURCE_DIRECT_PERCENT
    ||'"REF_DATE_DIRECT_PERCENT="'||rec.REF_DATE_DIRECT_PERCENT
    ||'"KIND_OF_CONTROL="'||rec.KIND_OF_CONTROL
    ||'"SOURCE_KIND_OF_CONTROL="'||rec.SOURCE_KIND_OF_CONTROL
    ||'"REF_DATE_KIND_OF_CONTROL="'||rec.REF_DATE_KIND_OF_CONTROL
    ||'"DATE_OF_COMMENCEMENT="'||rec.DATE_OF_COMMENCEMENT
    ||'"SOURCE_DATE_OF_COMMENCEMENT="'||rec.SOURCE_DATE_OF_COMMENCEMENT
    ||'"REF_DATE_OF_COMMENCEMENT="'||rec.REF_DATE_OF_COMMENCEMENT
    ||'"DATE_OF_CESSATION="'||rec.DATE_OF_CESSATION
    ||'"SOURCE_DATE_OF_CESSATION="'||rec.SOURCE_DATE_OF_CESSATION
    ||'"REF_DATE_OF_CESSATION="'||rec.REF_DATE_OF_CESSATION
    ||'"SOURCE_TA_OWNERSHIP="'||rec.SOURCE_TA_OWNERSHIP
    ||'"REF_DATE_TA_OWNERSHIP="'||rec.REF_DATE_TA_OWNERSHIP
    || '"/>'
    || CHR (10);
    XML_OW:=XML_OW||CHR(10)||TEMP_XML;
    idcounter := idcounter + 1;
    END LOOP;
    end;
    ----------------------

    Can you extend the test also with dbms_lob.writeappend? I am not on the same machine so so I am repeating all tests again (slightly modified):
    SQL> set timing on
    SQL> declare
       s   clob;
    begin
       s := dbms_random.string ('X', 10000);
       for j in 1 .. 100 * 100 * 10
       loop
          s := s || 'x';
       end loop;
       dbms_output.put_line ('Length: ' || length (s));     
    end;
    Length: 104000
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:20.49
    SQL> declare
       s   clob;
    begin
       s := dbms_random.string ('X', 10000);
       for j in 1 .. 100 * 100 * 10
       loop
          dbms_lob.append (s, 'x');
       end loop;
       dbms_output.put_line ('Length: ' || length (s));
    end;
    Length: 104000
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:25.49
    SQL> declare
       s        clob;
    begin
       dbms_lob.createtemporary (s, true);
       s := dbms_random.string ('X', 10000);
       for j in 1 .. 100 * 100 * 10
       loop
           dbms_lob.writeappend (s, 1, 'x');
       end loop;
       dbms_output.put_line ('Length: ' || length (s));
       dbms_lob.freetemporary (s);     
    end;
    Length: 104000
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:20.32So not much of a difference between first and third run ...

  • Appending a varchar2 to a clob

    I'm trying to append a varchar2 to a clob, using a package variable called glb_clob_var.
    if(xmlFlag = -1) then -- first time
    BEGIN
    glb_clob_var := inp_xmlMsg;
    END;
    end if;
    if(xmlFlag = 1) then -- neither first nor last time
    BEGIN
    dbms_lob.append(glb_clob_var, inp_xmlMsg);
    END;
    end if;
    However, I find that this append command just keeps the current value of inp_xmlMsg in glb_clob_var after each call to this procedure. That is, glb_clob_var is being overwritten instead of getting appended.
    Am I using the wrong call?

    However, I find that this append command just keeps the current value of inp_xmlMsg in
    glb_clob_var after each call to this procedure. That is, glb_clob_var is being overwritten instead of getting appended. But why do you think so?:
    SQL> DECLARE
       glb_clob_var   CLOB             := LPAD ('x', 32767) || LPAD ('y', 32767);
       inp_xmlmsg     VARCHAR2 (32767) := LPAD ('z', 32767);
    BEGIN
       DBMS_LOB.append (glb_clob_var, inp_xmlmsg);
       DBMS_OUTPUT.put_line (DBMS_LOB.getlength (glb_clob_var));
       DBMS_OUTPUT.put_line (3 * 32767);
    END;
    98301
    98301

  • Appending 2 CLOBs- Facing ORA-06502

    Hi All,
    Am trying to append a CLOB variable to another CLOB variable.
    Declare
    l_dest CLOB := ' ';
    l_src CLOB;
    CURSOR C1 IS
    <select cOLUMN_NAME1 FROM hz_parties>
    Begin
         FOR tmp_rec in C1
         LOOP
              Calls a procedure get_msg and outputs the data into l_src
    CLOB variable
              get_msg(tmp_rec.column_nam1,l_src);
              DBMS_LOB.APPEND(l_dest,l_src);
    END LOOP;
    END;
    The procedure is able to append the data to l_dest CLOB variable.But it is erroring out when the
    size of the l_dest CLOB variable reaches to 26213.
    Following error is thrown
    Code - ORA-06502: PL/SQL: numeric or value error.
    I have to put all the information fetched from the table into a CLOB variable. Finally i will be passing this CLOB variable to a API.
    I have gone through all the info about the DBMS_LOB.append,but culdnt able to resolve it....?
    If anyone has come across this situation.please let me know how to resolve it ??

    Exception is raised, when i call the DBMS_LOB.APPEND(l_dest,l_src);
    If i filter out the select statement in the cursor say rownum < 70; It is successfully appending the details to the l_dest CLOB. But if there are records with more than 70, then it is erroring out.
    get_msg(tmp_rec.column_nam1,l_src) is the procedure which just fetches the following
    fnd_message.set_name ('XXAAA', 'XXAA_VALIDATION');
    fnd_message.set_token ('source_info',pi_some_parameter);
    l_src := fnd_message.get;
    l_src := l_src||CHR(10)||CHR(10);

  • Appending to a zero length clob

    9.2.0.6
    this works:
    var myClob clob
    begin
    :myClob := to_clob(' ');
    for rec in (select * from delme1) loop
    dbms_lob.append(:myClob
    ,to_clob(rec.ename || '\n'));
    end loop;
    end;
    but this does not
    var myClob clob
    begin
    :myClob := to_clob('');
    for rec in (select * from delme1) loop
    dbms_lob.append(:myClob
    ,to_clob(rec.ename || '\n'));
    end loop;
    end;
    Seems like it does not like appending to a zero length clob. other than some trim thing how can I start at line zero.
    Thanks

    If you want to grasp an understanding about zero length strings then you should make yourself a coffee (or you may need several cups) and take a read of this thread:
    Treatment of zero-length strings as NULLs?
    But in short you should note that using a string '' is not a zero length string, but is considered to be NULL. Therefore your original clob, when using this is NULL.
    Consider the following instead...
    SQL> declare
      2    myClob clob;
      3  begin
      4  --  :myClob := to_clob('');
      5    for rec in (select ename from emp)
      6    loop
      7      IF NVL(dbms_lob.getlength(myClob),-1) < 1 THEN
      8        myClob := to_clob(rec.ename || '\n');
      9      ELSE
    10        dbms_lob.append(myClob, to_clob(rec.ename || '\n'));
    11      END IF;
    12    end loop;
    13    dbms_output.enable(1000000);
    14    dbms_output.put_line('Length');
    15    dbms_output.put_line(NVL(dbms_lob.getlength(myClob),-1));
    16  end;
    17  /
    Length
    98
    PL/SQL procedure successfully completed.
    SQL>

  • CLOB variable: concatenate or append?

    I just wrote a FUNCTION to return XML from a web service. As the text can go over 32,767 characters, i figured a CLOB was the way to go:
    FUNCTION Get_XML(I_URL VARCHAR2)
    RETURN XMLTYPE
    AS
      Page          CLOB;
      Response     UTL_HTTP.HTML_PIECES;
    BEGIN
      Response := UTL_HTTP.REQUEST_PIECES(I_URL);
      -- UTL_HTTP.REQUEST_PIECES returns 2000 byte chunks.
      FOR Chunk IN 1..Response.Count
      LOOP
       Page := Page || Response(Chunk);
      END LOOP;
      RETURN XMLTYPE(Page);
    END Get_XML;My question is, is about the best way to concatenate the pieces. Is Page := Page || Piece(Counter); good, or should i be using DBMS_LOB.APPEND or similar?

    Also, which is better, APPEND or WRITEAPPEND? They are different, each has it's own specific functionality, so instead of 'better', you mean 'suitable for my requirement'.
    See the Online Oracle Documentation regarding APPEND or WRITEAPPEND:
    "APPEND Procedures
    This procedure appends the contents of a source internal LOB to a destination LOB."
    http://docs.oracle.com/cd/B19306_01/appdev.102/b14258/d_lob.htm#sthref2972
    "WRITEAPPEND Procedures
    This procedure writes a specified amount of data to the end of an internal LOB."
    http://docs.oracle.com/cd/B19306_01/appdev.102/b14258/d_lob.htm#sthref3230
    Homepages:
    http://www.oracle.com/pls/db102/homepage
    http://www.oracle.com/pls/db112/homepage
    If APPEND, does it make sense to use TO_CLOB() on the piece for explicit conversion?APPEND expects a CLOB (or BLOB) as input, yes.
    And one more example from Tim Hall
    http://www.oracle-base.com/articles/misc/retrieving-html-and-binaries-into-tables-over-http.php

  • Can not Load CLOB data 32k to target table

    SQL> DESC testmon1 ;
    Name Null? Type
    FILENAME VARCHAR2(200)
    SCANSTARTTIME VARCHAR2(50)
    SCANENDTIME VARCHAR2(50)
    JOBID VARCHAR2(50)
    SCANNAME VARCHAR2(200)
    SCANTYPE VARCHAR2(200)
    FAULTLINEID VARCHAR2(50)
    RISK VARCHAR2(5)
    VULNNAME VARCHAR2(2000)
    CVE VARCHAR2(200)
    DESCRIPTION CLOB
    OBSERVATION CLOB
    RECOMMENDATION CLOB
    SQL> DESC test_target;
    Name Null? Type
    LOCALID NOT NULL NUMBER
    DESCRIPTION NOT NULL CLOB
    SCANTYPE NOT NULL VARCHAR2(12)
    RISK NOT NULL VARCHAR2(6)
    TIMESTAMP NOT NULL DATE
    VULNERABILITY_NAME NOT NULL VARCHAR2(2000)
    CVE_ID VARCHAR2(200)
    BUGTRAQ_ID VARCHAR2(200)
    ORIGINAL VARCHAR2(50)
    RECOMMEND CLOB
    VERSION VARCHAR2(15)
    FAMILY VARCHAR2(15)
    XREF VARCHAR2(15)
    create or replace PROCEDURE proc1 AS
    CURSOR C1 IS
    SELECT FAULTLINEID,VULNNAME,scanstarttime, risk,
    dbms_lob.substr(DESCRIPTION,dbms_lob.getlength(DESCRIPTION),1) "DESCR",dbms_lob.substr(OBSERVATION,dbms_lob.getlength(OBSERVATION),1) "OBS",
    dbms_lob.substr(RECOMMENDATION) "REC",CVE
    FROM testmon1;
    c_rec C1%ROWTYPE;
    descobs clob;
    FSCAN_VULN_TRANS_REC VULN_TRANSFORM_STG%ROWTYPE;
    TIMESTAMP varchar2(50);
    riskval varchar2(10);
    pCTX PLOG.LOG_CTX := PLOG.init (pSECTION => 'foundscanVuln Procedure',
    pLEVEL => PLOG.LDEBUG,
    pLOG4J => TRUE,
    pLOGTABLE => TRUE,
    pOUT_TRANS => TRUE,
    pALERT => TRUE,
    pTRACE => TRUE,
    pDBMS_OUTPUT => TRUE);
    amount number;
    buffer varchar2(32000);
    BEGIN
    ---INITIALIZE THE LOCATOR FOR CLOB DATA TYPE
    select observation into descobs from testmon1 where rownum=1;
    OPEN C1;
    loop
    fetch C1 INTO c_rec;
    exit when C1%NOTFOUND;
    --LOAD THE DESCRIPTION FIELD FROM CURSOR AND WRITE IT TO THE CLOB LOCATOR descobs.
    dbms_lob.Write(descobs,dbms_lob(c_rec.DESCR),1,c_rec.DESCR);
    ------APPEND THE OBSERVATION FIELD FROM CURSOR TO THE CLOB LOCATOR descobs.
    dbms_lob.Writeappend(descobs,dbms_lob(c_rec.DESCR),c_rec.OBS);
    -- dbms_output.put_line ('the timestamp is :'||c_rec.scanstarttime);
    --dbms_lob.write(descobs,amount,1,buffer);
    descobs:=c_rec.OBS;
    --dbms_lob.read(descobs,amount,1,buffer);
    --dbms_lob.append(c_rec.DESCR,c_rec.OBS);
    --descobs:=c_rec.OBS;
    --dbms_output.put_line ('the ADDED DESCROBS is :'||dbms_lob.substr(c_rec.DESCR,dbms_lob.getlength(c_rec.DESCR),1));
    dbms_output.put_line ('the ADDED DESCRIPTION AND OBSERVATION is :'||descobs);
    --dbms_output.put_line ('the DESCROBS buffer  is :'||buffer);
    SELECT DESCRIPTION INTO FSCAN_VULN_TRANS_REC.DESCRIPTION
    FROM TESTMON1 WHERE ROWNUM=1;
    ---------LOAD THE DESCRIPTION+ observation value into the target table description
    DBMS_LOB.WRITE(FSCAN_VULN_TRANS_REC.DESCRIPTION, dbms_lob.getlength(descobs),1,descobs);
    TIMESTAMP:=substr(c_rec.scanstarttime,1,10)||' '|| substr(c_rec.scanstarttime,12,8);
    IF c_rec.risk <3
    THEN riskval:='Low';
    ELSIF c_rec.risk <6
    THEN riskval:='Medium';
    ELSIF c_rec.risk <10
    THEN riskval:='High';
    END IF;
    FSCAN_VULN_TRANS_REC.TIMESTAMP:=TO_DATE(TIMESTAMP, 'YYYY/MM/DD HH24:MI:SS');
    FSCAN_VULN_TRANS_REC.risk:= riskval;
    --dbms_lob.append(c_rec.DESCR,c_rec.OBS);
    FSCAN_VULN_TRANS_REC.DESCRIPTION:=c_rec.DESCR;
    FSCAN_VULN_TRANS_REC.RECOMMEND:=c_rec.REC;
    FSCAN_VULN_TRANS_REC.LocalID:=to_number(c_rec.FAULTLINEID);
    FSCAN_VULN_TRANS_REC.SCANTYPE:='FOUNDSCAN';
    FSCAN_VULN_TRANS_REC.CVE_ID:=c_rec.CVE;
    FSCAN_VULN_TRANS_REC.VULNERABILITY_NAME:=c_rec.VULNNAME;
    -- dbms_output.put_line ('the plog timestamp is :'||timestamp);
    -- dbms_output.put_line ('the timestamp is :'||riskval);
    --dbms_output.put_line ('the recommend is :'||FSCAN_VULN_TRANS_REC.RECOMMEND);
    --dbms_output.put_line ('the app desc is :'||FSCAN_VULN_TRANS_REC.DESCRIPTION);
    insert into test_target values FSCAN_VULN_TRANS_REC;
    End loop;
    close C1;
    commit;
    EXCEPTION
    WHEN OTHERS THEN
    -- dbms_output.put_line ('Data not found');
    -----------dbms_output.put_line (sqlcode|| ':'||sqlerrm);
    end proc1;
    using dbms_lob package is not helping. Either DB stops responding. Or the Observation field ( which has max length >300000) can not be loaed into a CLOB variable.
    Please help or give me a sample code that helps.

    select     
         BANKING_INSTITUTION.BANK_REF_CODE     C1_BANK_ID,
         BANKING_INSTITUTION.NAME_BANK     C2_BANK_NAME,
         BANKING_INSTITUTION.BANK_NUMBER     C3_BANK_NUMBER,
         BANKING_INSTITUTION.ISO_CODE     C4_GBA_CODE,
         BANKING_INSTITUTION.STATUS     C5_STATUS,
         BANKING_INSTITUTION.SOURCE     C6_SOURCE,
         BANKING_INSTITUTION.START_DATE_BANK     C7_START_DATE,
         BANKING_INSTITUTION.ADDRESS_BANK     C8_BANK_ADDRESS1
    from     REF_DATA_DB.BANKING_INSTITUTION BANKING_INSTITUTION
    where     (1=1)
    insert /*+ append */ into XXSVB.C$_0XXSVB_BANKS_STAGING
         C1_BANK_ID,
         C2_BANK_NAME,
         C3_BANK_NUMBER,
         C4_GBA_CODE,
         C5_STATUS,
         C6_SOURCE,
         C7_START_DATE,
         C8_BANK_ADDRESS1
    values
         :C1_BANK_ID,
         :C2_BANK_NAME,
         :C3_BANK_NUMBER,
         :C4_GBA_CODE,
         :C5_STATUS,
         :C6_SOURCE,
         :C7_START_DATE,
         :C8_BANK_ADDRESS1
    )

  • Passing CLOB datatype to a stored procedure

    Hi,
    How do I pass a CLOB value to a stored procedure?
    I am creating a stored procedure which appends a value to a CLOB datatype. The procedure has 2 in parameter (one CLOB and one CLOB). The procedure is compiled but I'm having problem executing it. Below is a simplified version of the procedure and the error given when the procedure is executed.
    SQL> CREATE OR REPLACE PROCEDURE prUpdateContent (
    2 p_contentId IN NUMBER,
    3 p_body IN CLOB)
    4 IS
    5 v_id NUMBER;
    6 v_orig CLOB;
    7 v_add CLOB;
    8
    9 BEGIN
    10 v_id := p_contentId;
    11 v_add := p_body;
    12
    13 SELECT body INTO v_orig FROM test WHERE id=v_id FOR UPDATE;
    14
    15 DBMS_LOB.APPEND(v_orig, v_add);
    16 commit;
    17 END;
    18 /
    Procedure created.
    SQL> exec prUpdateContent (1, 'testing');
    BEGIN prUpdateContent (1, 'testing'); END;
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'PRUPDATECONTENT'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    Any help or hints please.
    null

    sorry I made a mistake with the in parameter types - it's one NUMBER and one CLOB.

  • CLOB datatype question

    Hi,
    I have a question regarding CLOB datatypes.
    The scenario is as follows:
    In our existing oracle 8i database, we have a tables say "inquiry" and another table "inq_details". The details table has a LONG field where we create a new record every time details for a specific inquiry is logged. The length of details can be any where from few characters to the field length.
    We are planning to move the DB to oracle 9i and I heard it is better to move from LONG to CLOB datatype.
    The question is If we log a new record (as it is today) for every detail record, should we be concerned with the data field size and retrieval performance?
    Am I better of appending the details to the same column instead of creating new record? (Only diff between two diff records is the details section nothing more than that). When we display the record, we always get all the details in the order in which they are logged.
    thank you

    A quick look in the manual would have shown you that LPAD returns the same datatype as its first argument : LPAD
    The string returned is of VARCHAR2 data type if expr1 is a character data type, NVARCHAR2 if expr1 is a national character data type, and a LOB if expr1 is a LOB data type.
    So, this works :
    SQL> declare
      2    r clob;
      3  begin
      4    r := lpad(to_clob('0'), 32768, '0');
      5  end;
      6  /
    PL/SQL procedure successfully completed

Maybe you are looking for

  • Connect iphone to smarttv for watching videos and pictures

    Trying to connect iphone to LGsmarttv for watching videos and pictures. We are on the same WIFI, pictures I can see, but no videos .... Do I need apple tv or an app ..

  • Convert video

    Hi. i just want to know if there is an aplication to convert ANY kind of video format to another kind of video format. for example: avi to quicktime, or mpg2 to iphone. etc...etc.... working and converting any video format to any format again. please

  • Simple type invalid value

    I have a form with a date field (using a simple type).  When I enter a text string into this field and try to save, I get an invalid context value error message for that field - as expected.  However, when I try to cancel the form, it does nothing un

  • Two accounting document generated for an invoice

    Hi , Friends I am facing a unique problem as two accounting document has been generated for a Invoice. Please suggest 1.  How is it possible 2.  What is possible solution temporary/ permanent . Regards Ajit

  • How long will it take to install Illustrator on a fast computer?

    How long will it take to install Illustrator on a fast computer?