DBMS_LOB.APPEND

DECLARE
l_data CLOB;
l_txt VARCHAR2(200);
BEGIN
l_txt := 'titus';
dbms_lob.append(l_data, l_txt);
END;
Hi,
When I execute the above PL/SQL block, i got the following exception.
ORA-06502: PL/SQL: numeric or value error: invalid LOB locator specified: ORA-22275
ORA-06512: at "SYS.DBMS_LOB", line 366
ORA-06512: at line 7.
Can anyone help to solve this?
Thanks In Advance
Titus

SQL>  declare
     l_data clob;
     l_txt  varchar2 (200);
begin
     dbms_lob.createtemporary (
          l_data,
          true
     l_txt := 'titus';
     dbms_lob.append (
          l_data,
          l_txt
     dbms_lob.freetemporary (l_data);
end;
PL/SQL procedure successfully completed.

Similar Messages

  • Using dbms_lob append to insert text how do you insert a new line inbetween

    DBMS_LOB.APPEND (P_TEXT,'* Operator Phone,');
    ---- inbetween I need to insert new I am using DBMS_LOB.APPEND (P_TEXT,CHR(10)); IS there amy better method?
    DBMS_LOB.APPEND (P_TEXT,'* Operator Email Address,');

    Sorry if the question was not clear ---
    Lets say in the folowing example every write append needs to start on a new line followed by text. How do we do that?
    Do we add another writeappend(cvar,22, chr(10)); inbetween?
    dbms_lob.writeappend(cvar, 19, '<root><book><title>');
    dbms_lob.writeappend(cvar, length(r.title), r.title);
    dbms_lob.writeappend(cvar, 14, '</title><desc>');
    dbms_lob.writeappend(cvar, length(r.description), r.description);
    dbms_lob.writeappend(cvar, 27, '</desc></book><author_name>');
    dbms_lob.writeappend(cvar, length(r.author_name), r.author_name);
    dbms_lob.writeappend(cvar, 21, '</author_name></root>');
    Edited by: user521218 on May 7, 2009 12:34 PM

  • Problem with DBMS_LOB.append() procedure

    Hi all.
    I have a small question about this function:
    I tried to use it to unit 2 CLOB objects. Here is part of my script:
    create or replace
    procedure PAGE_CSV()
    is
    S clob;
    S_FULL clob;
    begin
    DBMS_LOB.append(S_FULL, S);
    end;
    But I've got an error:
    ORA-19011: Character string buffer too small
    May be somebody knows what about his error? I Can not realize why it's about buffer (looks like varchar2), I do not use it...
    Thanks,
    Anton.
    PS Thats for sure, both of objects are not null.
    Edited by: user9050456 on Feb 9, 2010 5:44 AM

    You cannot assign to a lob variable a value larger then 32767 bytes if it doesn't have a persistent storage in the DB.
    SQL> declare
      2  a clob;
      3  begin
      4    a:=lpad('x',4001,'x');
      5    dbms_output.put_line(a);
      6  end;
      7  /
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    PL/SQL procedure successfully completed.
    SQL> declare
      2  a clob;
      3  begin
      4    a:=lpad('x',32768,'x');
      5    dbms_output.put_line(a);
      6  end;
      7  /
    declare
    ERROR at line 1:
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    ORA-06512: at line 4You have to do something like this:
    CREATE OR REPLACE PROCEDURE Example_1a IS
        dest_lob BLOB;
        src_lob  BLOB;
    BEGIN
        -- get the LOB locators
        -- note that the FOR UPDATE clause locks the row
        SELECT b_lob INTO dest_lob
            FROM lob_table
            WHERE key_value = 12 FOR UPDATE;
        SELECT b_lob INTO src_lob
            FROM lob_table
            WHERE key_value = 21;
        DBMS_LOB.APPEND(dest_lob, src_lob);
        COMMIT;
    EXCEPTION
        WHEN some_exception
        THEN handle_exception;
    END;Where both the source LOB and the destination one have a persistent storage on db.
    Max
    [My Italian Oracle blog| http://oracleitalia.wordpress.com/2010/02/07/aggiornare-una-tabella-con-listruzione-merge/]

  • 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 ...

  • Append a line to a text file

    hi,
    I'm using Oracle 11g.
    I'm storing text files in XML DB and accessing them using FTP, pl/sql and Java.
    Sometimes this files are huge, and all I need is to append a line.
    Is there any way to do this, without reading the full content of the file, using PL/SQL? Or Java?
    Thanks for all the help you can give me.

    procedure writeDebug(P_LOG_MESSAGE VARCHAR2)
    as
    pragma autonomous_transaction;
    V_LOG_CONTENT CLOB;
    V_LOG_BUFFER blob;
    V_SOURCE_OFFSET integer := 1;
    V_TARGET_OFFSET integer := 1;
    V_WARNING integer;
    V_LANG_CONTEXT integer := 0;
    V_DEBUG_CONTENT blob;
    begin
    createDebugOutputFile;
    update RESOURCE_VIEW
    set RES = updateXML(RES,'/Resource/DisplayName/text()',extractValue(RES,'/Resource/DisplayName/text()'))
    where equals_path(RES,G_DEBUG_OUTPUT_FILE) = 1;
    select extractValue(RES,'/Resource/XMLLob')
    into V_DEBUG_CONTENT
    from RESOURCE_VIEW
    where equals_path(RES,G_DEBUG_OUTPUT_FILE) = 1;
    V_LOG_CONTENT := chr(13) || chr(10) || to_char(systimestamp,'YYYY-MM-DD"T"HH24:MI:SS.FF') || ' : ' || P_LOG_MESSAGE;
    dbms_lob.createTemporary(V_LOG_BUFFER,true);
    dbms_lob.convertToBlob(V_LOG_BUFFER,V_LOG_CONTENT,dbms_lob.getLength(V_LOG_CONTENT),V_SOURCE_OFFSET,V_TARGET_OFFSET,nls_charset_id('AL32UTF8'),V_LANG_CONTEXT,V_WARNING);
    dbms_lob.freeTemporary(V_LOG_CONTENT);
    dbms_lob.open(V_DEBUG_CONTENT,dbms_lob.lob_readwrite);
    dbms_lob.append(V_DEBUG_CONTENT,V_LOG_BUFFER);
    dbms_lob.close(V_DEBUG_CONTENT);
    dbms_lob.freeTemporary(V_LOG_BUFFER);
    commit;
    end;

  • Use UNION / Append in PL/SQL

    Hello,
    I am using Oracle 11g R2 SOE. I have this procedure, and I would like to *"UNION" its* Select Statement with another Select Statement:
    declare
      v_xml clob;
      v_retval clob := '<?xml version="1.0" encoding="iso-8859-1"?>';
      v_blob blob;
    begin
    select
           xmlelement(
             "LISTINGS",
             xmlagg(
               xmlelement(
                 "LISTING",
                 xmlforest(
    'RS-'||R."RES_ID" as "Property_Ref_No",
    "UNIT_TYPE_LOOKUP"."UNIT_TYPE" as "Unit_Type",
    'Sale' as "Ad_Type",
    'Dubai' as "State",
    L.LOCATION_NAME_EN AS "Community",
    "PROJECTS"."PROJECT_NAME_EN" as "Property_Name",
    "RES_SALE"."ASKING_PRICE" as "Price",
    ' ' as "Frequency",
    ST."SUB_TYPE" as "Unit_Model",
    R."RES_SIZE" as "Unit_Builtup_Area",
    R.BEDS as "Bedrooms",
    R.bath as "No_of_Bathrooms",
    "RES_SALE"."AD_TITLE" as "Property_Title",
    RES_SALE.DESCRIPTION as "Web_Remarks",
    to_char("RES_SALE"."UPDATED_ON",'YYYY-MM-DD HH:MI:SSPM') as "Last_Updated",
    R.VIDEO as "Web_Tour",
    select xmlagg(
                                 xmlforest(
                                'http://thevillaproject.com/apex/erp/IMAGES/'||IMG.ID AS "ImageUrl"
    FROM      
          IMAGES IMG     
    WHERE IMG.RES_ID = R.RES_ID ) Images )))).getclobval()
      into      v_xml
      FROM
          "RES_SALE" "RES_SALE"
    inner join
          RES R on (R."RES_ID"="RES_SALE"."RES_ID")
    inner join
              "UNIT_STATUS_LOOKUP" on (UNIT_STATUS_LOOKUP.status_id = "RES_SALE"."RES_STATUS")
    inner join
          "PROJECTS" "PROJECTS" on ("PROJECTS"."PROJECT_ID"=R."PROJECT_ID")
    inner join
          "UNIT_TYPE_LOOKUP" "UNIT_TYPE_LOOKUP" on ("UNIT_TYPE_LOOKUP"."TYPE_ID"=R."RES_TYPE")
    inner join
          "RES_SUB_TYPE_LOOKUP" ST on (ST."SUB_TYPE_ID"=R."SUB_TYPE")
    INNER JOIN
          COMPLEX_LOOKUP CL ON (CL.COMPLEX_ID = "PROJECTS".COMPLEX_ID)
    INNER JOIN
          LOCATIONS L ON (L.LOCATION_ID = CL.LOCATION_ID)
    WHERE  "RES_SALE".RES_status IN (5,8) AND "RES_SALE".LIVE = 'Y' AND "RES_SALE".DESCRIPTION IS NOT NULL
      dbms_lob.append(v_retval,v_xml);
      OWA_UTIL.Mime_Header('text/xml'); 
      htp.p('Content-length: ' || to_char(dbms_lob.getlength(v_retval)));
      htp.p('Content-Disposition:  inline; filename="Just.xml"');
      owa_util.http_header_close;
      v_blob := wwv_flow_utilities.clob_to_blob(v_retval);
      wpg_docload.download_file(v_blob);
    end; h1. Select Statement that is needed to be "UNION-ED" with the Select Statement of the previous procedure:
    select
           xmlelement(
             "LISTINGS",
             xmlagg(
               xmlelement(
                 "LISTING",
                 xmlforest(
    'RR-'||R."RES_ID" as "Property_Ref_No",
    "UNIT_TYPE_LOOKUP"."UNIT_TYPE" as "Unit_Type",
    'Rent' as "Ad_Type",
    'Dubai' as "State",
    L.LOCATION_NAME_EN AS "Community",
    "PROJECTS"."PROJECT_NAME_EN" as "Property_Name",
    "RES_RENT"."ASKING_PRICE" as "Price",
    ' ' as "Frequency",
    ST."SUB_TYPE" as "Unit_Model",
    R."RES_SIZE" as "Unit_Builtup_Area",
    R.BEDS as "Bedrooms",
    R.bath as "No_of_Bathrooms",
    "RES_RENT"."AD_TITLE" as "Property_Title",
    "RES_RENT".DESCRIPTION as "Web_Remarks",
    to_char("RES_RENT"."UPDATED_ON",'YYYY-MM-DD HH:MI:SSPM') as "Last_Updated",
    R.VIDEO as "Web_Tour",
    select xmlagg(
                                 xmlforest(
                                'http://thevillaproject.com/apex/erp/IMAGES/'||IMG.ID AS "ImageUrl"
    FROM      
          IMAGES IMG     
    WHERE IMG.RES_ID = R.RES_ID ) Images ))))
    FROM
          "RES_RENT" "RES_RENT"
    inner join
          RES R on (R."RES_ID"="RES_RENT"."RES_ID")
    inner join
              "UNIT_STATUS_LOOKUP" on (UNIT_STATUS_LOOKUP.status_id = "RES_RENT"."RES_STATUS")
    inner join
          "PROJECTS" "PROJECTS" on ("PROJECTS"."PROJECT_ID"=R."PROJECT_ID")
    inner join
          "UNIT_TYPE_LOOKUP" "UNIT_TYPE_LOOKUP" on ("UNIT_TYPE_LOOKUP"."TYPE_ID"=R."RES_TYPE")
    inner join
          "RES_SUB_TYPE_LOOKUP" ST on (ST."SUB_TYPE_ID"=R."SUB_TYPE")
    INNER JOIN
          COMPLEX_LOOKUP CL ON (CL.COMPLEX_ID = "PROJECTS".COMPLEX_ID)
    INNER JOIN
          LOCATIONS L ON (L.LOCATION_ID = CL.LOCATION_ID)
    WHERE  "RES_RENT".RES_status IN (5,8) AND "RES_RENT".LIVE = 'Y' AND "RES_RENT".DESCRIPTION IS NOT NULL

    Hello Fateh,
    you can union both selects and then get the XML from the subquery.
    SELECT  XMLELEMENT(
                 "LISTINGS"
                ,XMLAGG(
                     XMLELEMENT(
                         "LISTING"
                        ,XMLFOREST(
                             rr_and_rs.ref_no AS "Property_Ref_No"
                            ,rr_and_rs."UNIT_TYPE" AS "Unit_Type"
                            ,'Sale' AS "Ad_Type"
                            ,'Dubai' AS "State"
                            ,rr_and_rs..location_name_en AS "Community"
                            ,rr_and_rs."PROJECT_NAME_EN" AS "Property_Name"
                            ,rr_and_rs."ASKING_PRICE" AS "Price"
                            ,' ' AS "Frequency"
                            ,rr_and_rs."SUB_TYPE" AS "Unit_Model"
                            ,rr_and_rs."RES_SIZE" AS "Unit_Builtup_Area"
                            ,rr_and_rs.beds AS "Bedrooms"
                            ,rr_and_rs.bath AS "No_of_Bathrooms"
                            ,rr_and_rs."AD_TITLE" AS "Property_Title"
                            ,rr_and_rs.description AS "Web_Remarks"
                            ,TO_CHAR(rr_and_rs."UPDATED_ON",'YYYY-MM-DD HH:MI:SSPM') AS "Last_Updated"
                            ,rr_and_rs.video AS "Web_Tour"
                            ,(  SELECT  XMLAGG(
                                             XMLFOREST(
                                                 'http://thevillaproject.com/apex/erp/IMAGES/'||img.id AS "ImageUrl"
                                FROM    images img
                                WHERE   img.res_id = rr_and_rs.res_id
                                ) Images
                ).getClobVal()
    INTO    v_xml
    FROM    (
        SELECT  'RR-'||r."RES_ID" AS ref_no
               ,"UNIT_TYPE_LOOKUP"."UNIT_TYPE"
               ,"RES_RENT"."ASKING_PRICE" AS price
        FROM    "RES_RENT" "RES_RENT"
                INNER JOIN res r
                  ON (r."RES_ID"="RES_RENT"."RES_ID")
                INNER JOIN "UNIT_STATUS_LOOKUP"
                  ON (unit_status_lookup.status_id = "RES_RENT"."RES_STATUS")
                INNER JOIN "PROJECTS" "PROJECTS"
                  ON ("PROJECTS"."PROJECT_ID"=r."PROJECT_ID")
                INNER JOIN "UNIT_TYPE_LOOKUP" "UNIT_TYPE_LOOKUP"
                  ON ("UNIT_TYPE_LOOKUP"."TYPE_ID"=r."RES_TYPE")
                INNER JOIN "RES_SUB_TYPE_LOOKUP" st
                  ON (st."SUB_TYPE_ID"=r."SUB_TYPE")
                INNER JOIN complex_lookup cl
                  ON (cl.complex_id = "PROJECTS".complex_id)
                INNER JOIN locations l
                  ON (l.location_id = cl.location_id)
        WHERE   "RES_RENT".res_status    IN (5,8)
        AND     "RES_RENT".live         = 'Y'
        AND     "RES_RENT".description IS NOT NULL
        UNION ALL
        SELECT  'RS-'||r."RES_ID" AS ref_no
               ,"UNIT_TYPE_LOOKUP"."UNIT_TYPE"
               ,"RES_SALE"."ASKING_PRICE" AS price
        FROM    "RES_SALE" "RES_SALE"
                INNER JOIN res r
                  ON (r."RES_ID"="RES_SALE"."RES_ID")
                INNER JOIN "UNIT_STATUS_LOOKUP"
                  ON (unit_status_lookup.status_id = "RES_SALE"."RES_STATUS")
                INNER JOIN "PROJECTS" "PROJECTS"
                  ON ("PROJECTS"."PROJECT_ID"=r."PROJECT_ID")
                INNER JOIN "UNIT_TYPE_LOOKUP" "UNIT_TYPE_LOOKUP"
                  ON ("UNIT_TYPE_LOOKUP"."TYPE_ID"=r."RES_TYPE")
                INNER JOIN "RES_SUB_TYPE_LOOKUP" st
                  ON (st."SUB_TYPE_ID"=r."SUB_TYPE")
                INNER JOIN complex_lookup cl
                  ON (cl.complex_id = "PROJECTS".complex_id)
                INNER JOIN locations l
                  ON (l.location_id = cl.location_id)
        WHERE   "RES_SALE".res_status    IN (5,8)
        AND     "RES_SALE".live         = 'Y'
        AND     "RES_SALE".description IS NOT NULL
        ) rr_and_rsUntested.
    When you want to keep two distinct selects (e.g. for easier maintainance), then have a look at INSERTCHILDXML. There you can add elements to an existing XML. http://docs.oracle.com/cd/E11882_01/appdev.112/e23094/xdb04cre.htm#ADXDB4289
    Regards
    Marcus
    BTW: Your mix of cases and case sensitive vs. case insensitive notation makes the code harder to read than necessary
    R.bath
    R.BEDS
    ST."SUB_TYPE"
    "RES_SALE"."ASKING_PRICE"Edited by: Marwim on 17.12.2012 13:15

  • DBMS_LOB.READ + ORA-06502

    Hello,
    I have the following function to convert a CLOB to a BLOB.
    function Clob_2_Blob (I_CLOB IN CLOB)
    return blob
    is
    v_rst BLOB := empty_blob();
    v_clob_length BINARY_INTEGER;
    v_blob BLOB := empty_blob();
    -- Param pour lire le CLOB.
    v_buffer VARCHAR2(32767);
    v_amount BINARY_INTEGER := 32767;
    v_position INTEGER := 1;
    BEGIN
    dbms_lob.createtemporary(v_rst,TRUE);
    v_clob_length := DBMS_LOB.GETLENGTH(I_CLOB);
    LOOP
    EXIT WHEN v_position > v_clob_length;
    dbms_lob.READ (I_CLOB, v_amount, v_position, v_buffer);
    v_blob := utl_raw.cast_to_raw(v_buffer);
    dbms_lob.append(v_rst,v_blob);
    v_position := v_position + v_amount;
    END LOOP;
    return v_rst;
    end Clob_2_Blob;
    When I use it, I get a ORA-06502 exception.
    If I change v_amount as follow
    v_amount BINARY_INTEGER := 32766;
    then I don't get any exception.
    I don't understand this because in theory, I can get up to 32767.
    What's wrong ?

    Hi Peter,
    It worked after i split the v_read_count to half. It means
    v_read_cnt   := 16383;The issue is when reading a character from the database it can get 'expanded' into two bytes. The chunk buffer can hold 32767 characters so if you read 16383 multi-byte characters from the database, it takes up twice the room (the 32766, one left over from rounding).
    Thanks

  • Help with appending blobs

    I have a table that holds multiple blobs i separate rows.
    What i am trying to do is have a procedure that will combine all of these blobs in a certain order and insert into a new table.
    I have the procedure below which does seem to work except for one major issue: it adds a null character ("00" in hex) between each append in the final blob.
    So i end up with the following
    [blob1_data]00[blob2_data]00[blob3_data]
    I have been searching for a solution for a while and could use some expert help.
    Here is what i have:
    PROCEDURE INSERT_ATTACHMENT()
    IS
    CURSOR curATTACH IS
    SELECT T.ATTACHMENT
    FROM NEMS.NEMS_INET_ATTACH_TEMP T
    WHERE T.ATTACH_KEY = pATTACH_KEY
    ORDER BY T.ATTACH_SEQ;
    blbATTACH NEMS.NEMS_ATTACHMENTS.ATTACHMENT%TYPE;
    BEGIN
    --combine blob seqments
    dbms_lob.createtemporary(blbATTACH, false);
    FOR lATTACH IN curATTACH LOOP
    dbms_lob.writeappend(blbATTACH, length(lATTACH.Attachment), lATTACH.Attachment);
    --dbms_lob.append(blbATTACH, lATTACH.Attachmnet);
    END LOOP;
    --insert into attachment table
    INSERT INTO NEMS.NEMS_ATTACHMENTS
    (ATTACHMENT)
    VALUES
    (blbATTACH);
    END INSERT_ATTACHMENT;

    Ah yes the version,
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0
    Also, i think i may have found a solution. I am going to test a few different files, but so far this looks promising:
    --combine blob seqments
    dbms_lob.createtemporary(blbATTACH, false);
    FOR lATTACH IN curATTACH LOOP
    dbms_lob.writeappend(blbATTACH, length(lATTACH.Attachment)-1, dbms_lob.substr(lATTACH.Attachment,length(lATTACH.Attachment)-1));
    END LOOP;

  • 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

  • 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>

  • Appending documents

    Hi,
    Is it possible to append two documents (PDF) stored as BLOBs in the database using the DBMS_LOB.append procedure to produce one single PDF document ?
    Is there any other solution to achieve the same ?
    Regards.

    You could store as many PDF documents togather within one BLOB upto the size limit, but it would not be equivalent of what you intend to do.
    The format of a PDF document is unknown as far as the BLOB (and DBMS_LOB package) is concerned. For them, its just stream of data coming in. It would in no way alter the structure of the existing PDF documents to merge them into one single document (DBMS_LOB.Append is to append more data to CLOB/BLOB, it is not for appending several documents into one).
    http://www.a-pdf.com/merger/index.htm
    http://www.adobe.com/epaper/tips/acr6mergedpdf/main.html

  • USER_DATASTORE: Could DBMS_LOB be leaking memory?

    We've got a database which is indexed with USER_DATASTORE and the following procedure. We're getting an occasional situation where this message appears in the alert log:
    ORA-04030: out of process memory when trying to allocate 8716 bytes (pga heap,Get krha asynch mem)
    CKPT: terminating instance due to error 4030
    Doing block recovery for file 2 block 81536
    ORA-04030: out of process memory when trying to allocate bytes (,) (several times)
    Instance terminated by CKPT, pid = 4900
    Starting up ORACLE RDBMS Version: 10.1.0.2.0.
    Could it be something in the procedure that is leaking or holding onto CLOBs longer than it should?
    Thanks!
    CREATE OR REPLACE PROCEDURE KM_TESTING_SMALLER_INDEX_PROC
    (RID IN ROWID, TLOB IN OUT CLOB) IS
    BEGIN
    DBMS_LOB.OPEN(TLOB,DBMS_LOB.LOB_READWRITE);
    DBMS_LOB.TRIM(TLOB,0);
    FOR C1 IN (SELECT REPLACE(BEGINBATES,'<',' ') BEGINBATES,
    REPLACE(ENDBATES,'<',' ') ENDBATES,
    REPLACE(DOCTITLE,'<',' ') DOCTITILE,
    REPLACE(OCR2,'<',' ') OCR2 FROM KM_TESTING_SMALLER WHERE ROWID=RID) LOOP
    DBMS_LOB.WRITEAPPEND(TLOB,20,'<BEGINBATESnxtfield>');
    IF (C1.BEGINBATES IS NOT NULL) THEN
    IF NOT(LENGTH(C1.BEGINBATES)=0) THEN
    DBMS_LOB.WRITEAPPEND(TLOB,LENGTH(C1.BEGINBATES),C1.BEGINBATES);
    END IF;
    END IF;
    DBMS_LOB.WRITEAPPEND(TLOB,39,'</BEGINBATESnxtfield><ENDBATESnxtfield>');
    DBMS_LOB.WRITEAPPEND(TLOB,36,'</DOCTYPEnxtfield><DOCTITLEnxtfield>');
    IF (C1.DOCTITLE IS NOT NULL) THEN
    IF NOT(LENGTH(C1.DOCTITLE)=0) THEN
    DBMS_LOB.APPEND(TLOB,C1.DOCTITLE);
    END IF;
    END IF;
    DBMS_LOB.WRITEAPPEND(TLOB,35,'</DOCTITLEnxtfield><AUTHORnxtfield>');
    DBMS_LOB.WRITEAPPEND(TLOB,27,'</CCnxtfield><OCR2nxtfield>');
    IF (C1.OCR2 IS NOT NULL) THEN
    IF NOT(LENGTH(C1.OCR2)=0) THEN
    DBMS_LOB.APPEND(TLOB,C1.OCR2);
    END IF;
    END IF;
    DBMS_LOB.WRITEAPPEND(TLOB,15,'</OCR2nxtfield>');
    END LOOP;
    DBMS_LOB.CLOSE(TLOB);
    END;

    Here is the documentation for ORA-04030:
    ORA-04030 out of process memory when trying to allocate string bytes (string,string)
    Cause: Operating system process private memory has been exhausted.
    Action: See the database administrator or operating system administrator to increase process memory quota. There may be a bug in the application that causes excessive allocations of process memory space.
    Generally speaking it means that the box hosting the database instance is running out of memory. You have some options:
    - decrease memory usage on the server (reduce PGA ? reduce SGA ? check any non-Oracle process memory usage)
    - add more RAM to your server.
    You check global statistics about PGA memory with:
    select * from v$pgastat;You can check PGA statistics for each server process with:
    select * from v$process;Note that the memory here is the PGA memory (not the SGA). PGA memory is private memory allocated by each Oracle server process (background process or dedicated server process).

  • DBMS_lob Parameters/Arguments

    Hello all!
    Can anyone point me to the correct documentation that contains a list of parameters/arguments for DBMS_lob calls? I have the developers guide that deals with LOBs, but haven't found a list of arguments yet. In particular, I am looking for the following:
    DBMS_lob.WRITE
    DBMS_lob.WRITEAPPEND
    DBMS_lob.APPEND
    DBMS_lob.FILEOPEN
    DBMS_lob.FILEGETNAME
    DBMS_lob.SUBSTR
    Any help would be greatly appreciated. Thank you!
    Steve

    http://download-east.oracle.com/docs/cd/B10501_01/appdev.920/a96612/d_lob2.htm#998404

Maybe you are looking for

  • Where to Look for Crash Causes

    Hi, G5 for 3 years; rock solid. Don't recall installing anything unusual (other than Apple SW updates) but twice now in the last week I have retunred to the system after being at work to find screen turned off and fans at full pelt. In the early days

  • EJB 3.0 - Destinations not specified

    Hi, I  am trying to deploy a J2EE application supporting EJB 3.0 on SAP CE 7.1 . During the deployment using NWDS , i am getting the error as "Destinations not specified". However , i have already preformed below listed steps : --> I have specified t

  • Error 7 windows error 14001

         When I download iTunes & try to open it, and error pops up that says "iTunes was not installed correctly. Please reinstall iTunes. Error 7 (Windows error 14001)" I tried uninstalling & reinstalling at least 12 times, nothing changed. I've tried

  • Safari 2.0.3 doesn't "remember" My Yahoo login, more

    For the last few days, even though I have "remember me" checked in my "My Yahoo!" home page, every time I exit Safari and reopen it, i get the My Yahoo sign up page. Same goes for Amazon 1-click, Google preferences, VersionTracker's log in, etc. I sp

  • Lost disk space after formatting drive

    Hi folks, about 2 months ago I bought an 320GB IDE drive for my win machine. Recently I decided to put it in an old FW case to use it for TimeMachine. The external case always did an excellent job so far. When mounting the drive, I could see it was 3