Datastore for CLOB

What datastore should be used for a context index on a CLOB column? I used Java to load large text file into Oracle 8i in a CLOB column, then created a context index on it. But the searching does not work. Please help!

The default one should be fine if you store the text in database.
Something like this:
1. create table quick_clob (
quick_id number primary key,
filename varchar2(2000),
text clob
2. The load text with sqlldr:
sqlldr userid=test/test control=load.ctl log=load.log
Or loading text using any other mechanism.
3. create index text_index on quick_clob(text)
indextype is ctxsys.context ;
You should be able to search then.

Similar Messages

  • SQLloder scripts not getting generated for CLOBs

    I am trying to migrate MYSQL 3.23 database into Oracle 8.1.7 and after creating the Oracle model and after converting the MYSQL text datatype into CLOB of the Oracle model the SQLloader scripts is not getting generated for CLOB datatypes. I mean the scripts are getting created but there is no change in the script for CLOB datatype.
    The script generates the following for the table containing CLOB datatypes:
    mysqldump -h <HOST> -u <USERNAME> -p<PASSWORD> -T <DESTINATION_PATH> fields-terminated-by="<ec>" lines-terminated-by="<er>" test av_wbt_course
    Please let me know how to load data when the datatype is of CLOB ?

    I was able to resolve this issue by using OWM Oracle Migration instead of using offline method by sqlloader scripts.

  • Limitation for CLOB columns? - ORA-01704: string literal too long

    Hello!
    I'm trying to update a CLOB column with more than 35000 characteres, but I get "ORA-01704: string literal too long".
    The code:
    declare
    l_clob clob;
    begin
    update test set test = empty_clob()
    WHERE ID = 1
    returning test into l_clob;
    dbms_lob.write( l_clob, length('A...here 35000xA...A'), 1,'A...here 35000xA...A');
    end;
    Is there any limitation for CLOB columns?
    Thanks for help.
    Daniel

    user605489 wrote:
    32768 characteres :)Actually it's 1 character less than 32K...
    *32767*
    SQL> declare
      2    v_vc varchar2(32768);
      3  begin
      4    null;
      5  end;
      6  /
      v_vc varchar2(32768);
    ERROR at line 2:
    ORA-06550: line 2, column 17:
    PLS-00215: String length constraints must be in range (1 .. 32767)
    SQL>I guess it comes from a legacy thing where signed words (2 bytes) are/were used to represent a value. As the most significant bit of the word is used to represent the sign of the number the range goes from -32768 to 32767.

  • Problem w. hash-value calculation for CLOB with DBMS_UTILITY.GET_HASH_VALUE

    Hello Oracle-Experts,
    I had to calculate hash-values for a corrorponding CLOB-field (see my post 'Buffer to small ORA-22835 error after migration from 9i to 10g' in forum 'database general').
    I calculate the hash-values with the DBMS_UTILITY.GET_HASH_VALUE, e.g:
         SQL> SELECT DBMS_UTILITY.GET_HASH_VALUE(LPAD('X',3998,'X'),1,POWER(2,30)) FROM dual;
         DBMS_UTILITY.GET_HASH_VALUE(LPAD('X',3998,'X'),1,POWER(2,30))
         1053896858
    Because the calculation failed with 10g I had taken a closer look at this function and realised the following results:
    VALUE                                             DBMS_UTILITY.GET_HASH_VALUE(VALUE,1,POWER(2,30))
    LPAD('X',3997,'X') 557754150
    LPAD('X',3998,'X')      1053896858
    LPAD('X',3999,'X')          888036750
    LPAD('X',4000,'X') 162062978
    LPAD('X',4001,'X')          162062978
    LPAD('X',4002,'X') 162062978
    LPAD('X',10000,'X') 162062978
    It seems to me that I can't use this function for clob-values with a length greater than 4000 characters because of collisions. Maybe someone with experience
    can give me a hint to handle this problem. Worst case i had to write my own CLOB_2_HASH function.
    TIA + Best regards
    Matthias

    Yeah, the 4000-byte limit would be a factor in working CLOBs. I if you only had 4000 bytes you would not need a CLOB in the first place.
    If you don't find something better then writing your own function might be the thing to do.

  • ORA-22835: Buffer too small for CLOB to CHAR or BLOB to RAW conversion

    Hi all,
    the following query select to_char(nvl(round(pc.target_cost*xx_primavera.geteurtolvrate,2),amount),'FM999G999G999G999G990D00') detail_amount,
    nvl(ct.cost_type, description) detail_description,
    tm_desc.memo_id,
    primavera_prj_name detail_prj_name,
    hp.party_number detail_party_number,
    xpid.interface_line_attribute1,
    utl_i18n.unescape_reference(replace(regexp_replace(utl_raw.cast_to_varchar2(tm_desc.task_memo), '<[^>]*>'), chr(13)||chr(10))) document_description,
    REPLACE(regexp_replace(utl_raw.cast_to_varchar2(tm_id.task_memo), '<[^>]*>'), chr(13)||chr(10)) prim_memo_client_id
    from XX_PRIMAVERA_INVOICES_DETAIL xpid
    join admuser.xx_ar_hz_parties xahp on xahp.orig_system_bill_customer_id = xpid.orig_system_bill_customer_id
    join hz_parties hp on hp.party_id = xahp.party_id
    left join admuser.projcost pc on pc.proj_id = xpid.primavera_prj_id and pc.cost_type_id != 29 and xpid.service_code = 8 and pc.task_id = xx_primavera.getTaskId(xpid.primavera_prj_id,'A1020', 'Изготвяне на оферта') and delete_session_id is null
    left join admuser.costtype ct on ct.cost_type_id = pc.cost_type_id
    left join admuser.taskmemo tm_id on tm_id.proj_id = xpid.primavera_prj_id and tm_id.memo_type_id = 53 and tm_id.task_id = xx_primavera.getTaskId(xpid.primavera_prj_id,'A1020', 'Изготвяне на оферта')
    left join admuser.taskmemo tm_desc on tm_desc.proj_id = xpid.primavera_prj_id and tm_desc.memo_type_id = 55 and tm_desc.task_id = xx_primavera.getTaskId(xpid.primavera_prj_id,'A1020', 'Изготвяне на оферта')
    where amount != 0
      and xpid.interface_line_attribute1 = :ra_ctp_attribute1
    ORDER BY xpid.primavera_prj_name, xpid.description;returns error:
    ORA-22835: Buffer too small for CLOB to CHAR or BLOB to RAW conversion (actual: 2371, maximum: 2000) I found that the error occurs in the row : utl_i18n.unescape_reference(replace(regexp_replace(utl_raw.cast_to_varchar2(tm_desc.task_memo), '<[^>]*>'), chr(13)||chr(10))) document_description,and tried to change it to: utl_i18n.unescape_reference(replace(regexp_replace(utl_raw.cast_to_varchar2(dbms_lob.substr(tm_desc.task_memo,1,2000)), '<[^>]*>'), chr(13)||chr(10))) document_description,....but it returns not value for that field... am i using dbms_lob.substr at the wrong place? The column 'tm_desc.task_memo' is BLOB type.
    Any ideas how to cheat it ?
    Version: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
    PL/SQL Release 11.1.0.7.0 - Production
    "CORE     11.1.0.7.0     Production"
    TNS for Linux: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - ProductionThanks in advance,
    Bahchevanov.

    Your second example has the parameters reversed. The amount (length) comes first and then the offset:
    DBMS_LOB.SUBSTR (
       lob_loc     IN    BLOB,
       amount      IN    INTEGER := 32767,
       offset      IN    INTEGER := 1)
      RETURN RAW;
    DBMS_LOB.SUBSTR (
       lob_loc     IN    CLOB   CHARACTER SET ANY_CS,
       amount      IN    INTEGER := 32767,
       offset      IN    INTEGER := 1)
      RETURN VARCHAR2 CHARACTER SET lob_loc%CHARSET;
    DBMS_LOB.SUBSTR (
       file_loc     IN    BFILE,
       amount      IN    INTEGER := 32767,
       offset      IN    INTEGER := 1)
      RETURN RAW;Also, remember that # of bytes is not necessarily the same as the # of characters depending on your character set. So 2000 bytes might become 4000 characters. And you have to make sure the BLOB is actually character data and not arbitrary binary data.
    Post the results of reversing the parameters and using a smaller chunk size.

  • Comparison for clob type

    Hi All,
    Can Anyone please tell how to compare clob type in select query with where condition ?
    Ex: field: Desc_ short(Clob )
    field ean_code(number,pk)
    And i want to see those ean_code list matching to particullar clob pattern matching in the record in any where in the record.
    Please help.
    Thanks and regards,
    DK.

    COMPARE function
    This function compares two entire LOBs or parts of two LOBs. You can only compare LOBs of the same datatype (LOBs of BLOB type with other BLOBs, and CLOBs with CLOBs, and BFILEs with BFILEs). For BFILEs, the file must be already opened using a successful FILEOPEN operation for this operation to succeed.
    COMPARE returns zero if the data exactly matches over the range specified by the offset and amount parameters. Otherwise, a non-zero INTEGER is returned.
    For fixed-width n-byte CLOBs, if the input amount for COMPARE is specified to be greater than (4294967295/n), then COMPARE matches characters in a range of size (4294967295/n), or Max(length(clob1), length(clob2)), whichever is lesser.
    Syntax
    DBMS_LOB.COMPARE (
       lob_1            IN BLOB,
       lob_2            IN BLOB,
       amount           IN INTEGER := 4294967295,
       offset_1         IN INTEGER := 1,
       offset_2         IN INTEGER := 1)
      RETURN INTEGER;
    DBMS_LOB.COMPARE (
       lob_1            IN CLOB  CHARACTER SET ANY_CS,
       lob_2            IN CLOB  CHARACTER SET lob_1%CHARSET,
       amount           IN INTEGER := 4294967295,
       offset_1         IN INTEGER := 1,
       offset_2         IN INTEGER := 1)
      RETURN INTEGER;
    DBMS_LOB.COMPARE (
       lob_1            IN BFILE,
       lob_2            IN BFILE,
       amount           IN INTEGER,
       offset_1         IN INTEGER := 1,
       offset_2         IN INTEGER := 1)
      RETURN INTEGER;
    Pragmas
    pragma restrict_references(COMPARE, WNDS, WNPS, RNDS, RNPS);
    Parameters
    Table 17-7 COMPARE Function Parameters
    Parameter  Description 
    lob_1        LOB locator of first target for comparison. 
    lob_2        LOB locator of second target for comparison. 
    amount  Number of bytes (for BLOBs) or characters (for CLOBs) to compare. 
    offset_1  Offset in bytes or characters on the first LOB (origin: 1) for the comparison. 
    offset_2  Offset in bytes or characters on the first LOB (origin: 1) for the comparison. 
    Returns
    INTEGER: Zero if the comparison succeeds, non-zero if not.
    NULL, if
    amount < 1
    amount > LOBMAXSIZE
    offset_1 or offset_2 < 1
    offset_1 or offset_2 > LOBMAXSIZE
    Exceptions
    Table 17-8 COMPARE Function Exceptions for BFILE operations
    Exception  Description 
    UNOPENED_FILE
      File was not opened using the input locator. 
    NOEXIST_DIRECTORY
      Directory does not exist. 
    NOPRIV_DIRECTORY
      You do not have privileges for the directory. 
    INVALID_DIRECTORY
      Directory has been invalidated after the file was opened. 
    INVALID_OPERATION
      File does not exist, or you do not have access privileges on the file.
    http://www.java2s.com/Code/Oracle/System-Packages/Usedbmslobcomparetocompare.htm

  • XQuery for (CLOB)-XMLType

    I would like to know whether XQuery is supporting XMLType (CLOB).
    It seems to be possible to apply XQuery on a sqlquery by using the command sqlquery(..) according to FOR $b IN sqlquery(..)
    This however throws a parsing excpetion when I use an sql-query that contains the extract statement which is used for CLOBs
    Please help !
    Below a piece of code that is not running..
    FOR $b IN sqlquery("select extract( doc,'/MeasurementSystems/' ).getStringVal() from V34_6jisno7sf3ksve4m5pabk33h1b X")/MeasurementSystems/MeasurementSeries/*

    Marcel,
    Does the extract work outside of the sqlquery and FOR loop?

  • APEX BUG ?  Buffer too small for CLOB to CHAR or BLOB to RAW

    Hi
    I tried use search field (right top corner) in Application Builder for my APP. After while a had:
    report error:
    ORA-22835: Buffer too small for CLOB to CHAR or BLOB to RAW conversion (actual: 8000, maximum: 4000)
    I changed my main table and now I would like search every appearance in app, I thought it's the best solution to use search.
    Do you know how resolve my problem.
    APEX ver 4.0.1.00.03

    You can't...there's a limit of 4k for any page item in apex....attempting to convert or bring in more into a page item or even from an app process into a javascript variable, kicks that error.
    It's a limitation with mod_plsql, there's a fix in 4.0 but it requires using the java listener instead of mod_plsql.

  • ORA-22835: Buffer too small for CLOB to CHAR  on Solaris but not Windows

    Hi,
    I get the following error on Solaris but not Windows equivalent 10.2 installations
    ORA-22835: Buffer too small for CLOB to CHAR or BLOB to RAW conversion (actual: 4575, maximum: 4000)
    ORA-06512: at line 65
    the code causing the problem is:
    SELECT A.TABLE_NAME, A.DEFAULT_DIRECTORY_NAME, B.LOCATION,
    CASE
    WHEN INSTR(A.ACCESS_PARAMETERS,'RECORDS FIXED')<>0 THEN
    SUBSTR(A.ACCESS_PARAMETERS,INSTR(A.ACCESS_PARAMETERS,'RECORDS FIXED')+14,3)
    ELSE NULL
    END RSZ FROM USER_EXTERNAL_TABLES A, USER_EXTERNAL_LOCATIONS B
    WHERE A.TABLE_NAME = B.TABLE_NAME(+);
    the entire code being executed is:
    DECLARE
    EX BOOLEAN;
    CNT NUMBER;
    SQL1 VARCHAR2(4000);
    FLEN NUMBER;
    BSIZE NUMBER;
    TABNAME VARCHAR2(4000);
    DEFDIR VARCHAR2(4000);
    RSZ VARCHAR2(4000);
    ECODE NUMBER(38);
    ERRMSG VARCHAR2(4000);
    CURSOR C1 IS
    SELECT A.TABLE_NAME, A.DEFAULT_DIRECTORY_NAME, B.LOCATION,
    CASE
    WHEN INSTR(A.ACCESS_PARAMETERS,'RECORDS FIXED')<>0 THEN
    SUBSTR(A.ACCESS_PARAMETERS,INSTR(A.ACCESS_PARAMETERS,'RECORDS FIXED')+14,3)
    ELSE NULL
    END RSZ FROM USER_EXTERNAL_TABLES A, USER_EXTERNAL_LOCATIONS B
    WHERE A.TABLE_NAME = B.TABLE_NAME(+);
    TYPE C1_TYPE IS TABLE OF C1%ROWTYPE;
    REC1 C1_TYPE;
    BEGIN
    OPEN C1;
    FETCH C1 BULK COLLECT INTO REC1;
    FOR I IN REC1.FIRST .. REC1.LAST
    LOOP
    UTL_FILE.FGETATTR(NVL(REC1(I).DEFAULT_DIRECTORY_NAME,'CARDSLOAD'),
    REC1(I).LOCATION, EX, FLEN, BSIZE);
    IF EX THEN
    IF INSTR(TO_CHAR(REC1(I).RSZ),'\.')<>0 THEN
         DBMS_OUTPUT.PUT_LINE('INVALID RECORDSIZE OR CORRUPTED FILE');
         END IF;
         DBMS_OUTPUT.PUT_LINE('Table Name: ' || TO_CHAR(REC1(I).TABLE_NAME));     
    DBMS_OUTPUT.PUT_LINE('File Exists '||REC1(I).LOCATION);
         DBMS_OUTPUT.PUT_LINE('File Length: ' || TO_CHAR(FLEN));
         DBMS_OUTPUT.PUT_LINE('Record Size: ' || TO_CHAR(REC1(I).RSZ));
    DBMS_OUTPUT.PUT_LINE('Block Size: ' || TO_CHAR(BSIZE));
         DBMS_OUTPUT.PUT_LINE('# RECORDS: ' || FLEN/TO_NUMBER(REC1(I).RSZ));
         BEGIN
         CNT:='';
         SQL1:='SELECT COUNT(*) FROM '|| REC1(I).TABLE_NAME;
         EXECUTE IMMEDIATE SQL1 INTO CNT;
    DBMS_OUTPUT.PUT_LINE('SELECT COUNT FOR: ' || REC1(I).TABLE_NAME||' = '||CNT);
         EXCEPTION
         WHEN OTHERS THEN
         DBMS_OUTPUT.PUT_LINE('SELECT COUNT FAILED FOR: ' || REC1(I).TABLE_NAME);
         ECODE := SQLCODE;
    ERRMSG := SQLERRM;
    DBMS_OUTPUT.PUT_LINE(ECODE||' '||ERRMSG);
         END;
    ELSE
    DBMS_OUTPUT.PUT_LINE(REC1(I).TABLE_NAME||' '||REC1(I).LOCATION||' File Does Not Exist');
    END IF;
         DBMS_OUTPUT.PUT_LINE('-----------------------------------------------------');
    END LOOP;
    CLOSE C1;
    EXCEPTION
    WHEN OTHERS THEN RAISE;
    END;
    Any ideas why Solaris but not Windows would have this problem?
    Thanks,
    Victor

    Check out Bug 4715104 - ORA-22835 / truncated data from USER/ALL/DBA_EXTERNAL_TABLES

  • Report error: ORA-22835: Buffer too small for CLOB to CHAR or BLOB to RAW c

    report error:
    ORA-22835: Buffer too small for CLOB to CHAR or BLOB to RAW conversion (actual: 7106, maximum: 4000)
    Has anyone come across this error?
    We're inputing text using the HTML Editor Minimal. The text is saving fine, but large text inputs, when combined with the html tags, cannot be retrieved from the database, i just get the above error. I believe there is an associated DB bug for this, but i'm curious if anyone has come across this before, and if they found a work-around?

    Did you solve this?
    I have a similar problem, as posted in CLOBs Quit Working Due to > 4000 chars - ORA-22835
    Thanks,
    --BobC                                                                                                                                                                                                                                                                                           

  • What control i can use for Clob datatype in forms?

    Hi,
    Backend side
    I had created a table that having a column namely sql_text which hold the query string and defined as CLOB data type.
    On Form 6i
    Just i created a textitem(long) for the clob datatype field
    but it only hold very limited length of charter, i want to be more. Any other control is there?
    please guid me what should i want to do.
    kanish

    There is limited support for CLOBs in Forms. I guess you could read it in piecemeal with a procedure using the DBMS_LOB package

  • User Datastore for multiple tables and columns!

    Hi,
    I hop so much, someone can help me.
    I've made a user datastore to index multiple columns of multiple tables.
    Now, the Documentation of Oracle explains the idexing of one table.
    I have multiple tables, which have all, the columns descr and tagnr. I want to make a query sth like this:
    select table1.column, table2.columnd... where contains(indexed field,'gas within descr',1)>0
    is it possible to index 4 seperate tables, without having a collective key? I dont want to make a Concatenated Datastore.
    I have wrote this code.
    But it doesn't work. It's been compiled fine. But I don't get any result with my queries.
    create or replace
    procedure My_Proc_Wide
    Must be in ctxsys schema.
    In a full-scale example, this would be a wrapper
    for a proc in the user schema.
    rid in rowid,
    tlob in out NOCOPY clob /* NOCOPY instructs Oracle to pass
    this argument as fast as possible */
    is
    v_descr varchar2(80);
    v_tagnr varchar2(30);
    v_descr_name constant varchar2(20) := 'descr';
    v_descr_start_tag constant varchar2(20) := '<' || v_descr_name || '>';
    v_descr_end_tag constant varchar2(20) := '</' || v_descr_name || '>';
    v_tagnr_name constant varchar2(20) := 'tagnr';
    v_tagnr_start_tag constant varchar2(20) := '<' || v_tagnr_name || '>';
    v_tagnr_end_tag constant varchar2(20) := '</' || v_tagnr_name || '>';
    v_buffer varchar2(4000);
    v_length integer;
    begin
    /* verify the env which called this */
    if Dbms_Lob.Istemporary ( tlob ) <> 1
    then
    raise_application_error ( -20000,
    '"IN OUT" tlob isn''t temporary' );
    end if;
    /* the real logic */
    /* first tabel to be indexed */
    select t1.tagnr, t1.descr
    into v_tagnr, v_descr
    from tweb.pdp_positions t1
    where t1.rowid = rid;
    v_buffer := v_tagnr_start_tag ||
    v_tagnr ||
    v_tagnr_end_tag ||
    v_descr_start_tag ||
         v_descr ||
         v_descr_end_tag;
    v_length := length ( v_buffer );
    Dbms_Lob.WriteAppend(tlob, length(v_buffer) + 1, v_buffer || ' ');
    /* second table to be indexed */
    select t2.tagnr, t2.descr
    into v_tagnr, v_descr
    from tweb.pdp_schema_equ t2
    where t2.rowid = rid;
         v_buffer := v_tagnr_start_tag ||
    v_tagnr ||
    v_tagnr_end_tag ||
    v_descr_start_tag ||
         v_descr ||
         v_descr_end_tag;
    v_length := length ( v_buffer );
    Dbms_Lob.WriteAppend(tlob, length(v_buffer) + 1, v_buffer || ' ');
    /*third table to be indexed */
    select t3.tagnr, t3.descr
    into v_tagnr, v_descr
    from tweb.pdp_equipment t3
    where t3.rowid = rid;
         v_buffer := v_tagnr_start_tag ||
    v_tagnr ||
    v_tagnr_end_tag ||
    v_descr_start_tag ||
         v_descr ||
         v_descr_end_tag;
    v_length := length ( v_buffer );
    Dbms_Lob.WriteAppend(tlob, length(v_buffer) + 1, v_buffer || ' ');
    /* fourth table to be indexed */
    select t4.tagnr, t4.descr
    into v_tagnr, v_descr
    from tweb.pdp_Projcode t4
    where t4.rowid = rid;
         v_buffer := v_tagnr_start_tag ||
    v_tagnr ||
    v_tagnr_end_tag ||
    v_descr_start_tag ||
         v_descr ||
         v_descr_end_tag;
    v_length := length ( v_buffer );
    Dbms_Lob.WriteAppend(tlob, length(v_buffer) + 1, v_buffer || ' ');
    end My_Proc_Wide;
    what have I to do, to make this work?
    Any Help would be appriciated!!
    Kind Regards,
    Arsineh

    Arsineh,
    I realise that it has been quite some time since you posted this question but I thought I'd reply just in case you never did manage to get your user datastore working.
    The reason your procedure will not work is simple. A user datastore procedure accepts a rowid input parameter. The rowid is the ID of the row that Oracle Text is currently trying to index. In the example you have given, you are attempting to use the supplied rowid as the primary key for multiple tables, this will simply never work as the rowid's across multiple tables will never correspond.
    The best way to achieve your goal is to create the index on a master table which contains the common primary keys for each of your four tables e.g.
    MASTER_TABLE
    COL:COMMON_KEY (NUMBER(n))
    COL:USER_INDEX_COLUMN (VARCHAR2(1))
    If you create the user datastore index on the MASTER_TABLE.USER_UNDEX_COLUMN column your stored proc simply needs to read the correct row from the MASTER_TABLE (SELECT t.common_key into v_CommonKey FROM master_table t WHERE t.rowid = rid) and issue subsequent queries to extract the relavant data from the t1..t4 tables using the common key e.g.
    SELECT t1.tagnr, t1.descr into v_tagnr, v_descr FROM t1 WHERE t1.[PRIMARY_KEY_FIELD] = v_CommonKey;
    SELECT t2.tagnr, t2.descr into v_tagnr, v_descr FROM t2 WHERE t2.[PRIMARY_KEY_FIELD] = v_CommonKey;
    and so on...
    Hope this helps
    Dean

  • What's the best way to create and free temporaries for CLOB parameters?

    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production on Solaris
    I have a procedure calling another procedure with one of the parameters being an IN OUT NOCOPY CLOB.
    I create the temporary CLOB in proc_A, do the call to proc_B and then free the temporary again.
    In proc_B I create a REFCURSOR, and use that with dbms_xmlgen to create XML.
    So the code basically looks like
    CREATE OR REPLACE PROCEDURE client_xml( p_client_id IN            NUMBER
                                           ,p_clob      IN OUT NOCOPY CLOB   ) AS
       v_rc         SYS_REFCURSOR;
       v_queryCtx   dbms_xmlquery.ctxType;
    BEGIN
       OPEN c_rc FOR
          SELECT col1
                ,col2
                ,col3
            FROM clients
           WHERE client_id = p_client_id;
       v_queryCtx := dbms_xmlgen.newContext(v_rc);
       p_clob     := dbms_xmlgen.getXML(v_queryCtx, 0);
    END;
    CREATE OR REPLACE PROCEDURE my_proc AS
       v_clob       CLOB;
       v_client_id  NUMBER;
    BEGIN
       v_client_id := 123456;
       dbms_lob.createTemporary(v_clob, TRUE, dbms_lob.CALL);
       client_xml( p_client_id => v_client_id
                  ,p_clob      => v_clob);
       dbms_lob.freeTemporary(v_clob);
    END;However, I just learned the hard way that IN OUT NOCOPY is only a hint, and that Oracle sometimes creates a local variable for the CLOB anyway.
    A solution is to change the client_xml procedure above to
    CREATE OR REPLACE PROCEDURE client_xml( p_client_id IN            NUMBER
                                           ,p_clob      IN OUT NOCOPY CLOB   ) AS
       v_rc         SYS_REFCURSOR;
       v_queryCtx   dbms_xmlquery.ctxType;
    BEGIN
       IF NOT NVL(dbms_lob.istemporary(p_clob),0) = 1 THEN
          dbms_lob.createTemporary(p_clob, TRUE, dbms_lob.CALL);
       END IF;
       OPEN c_rc FOR
          SELECT col1
                ,col2
                ,col3
            FROM clients
           WHERE client_id = p_client_id;
       v_queryCtx := dbms_xmlgen.newContext(p_refcursor);
       p_clob     := dbms_xmlgen.getXML(v_queryCtx, 0);
    END;My concern is that in case Oracle does create a local variable, 2 temporaries will be created, but there will only be 1 freeTemporary.
    Could this lead to a memory leak?
    Or should I be safe with the solution above because I'm using dbms_lob.CALL?
    Thanks,
    Arnold
    Edited by: Arnold vK on Jan 24, 2012 11:52 AM

    Arnold vK wrote:
    However, I just learned the hard way that IN OUT NOCOPY is only a hint, and that Oracle sometimes creates a local variable for the CLOB anyway.A CLOB variable in called a locator. Just another term for a pointer.
    A CLOB does not exist in local stack space. The variable itself can be TBs in size (max CLOB size is 128TB depending on DB config) - and impossible to create and maintain in the stack. Thus it does not exist in the stack - and is why the PL/SQL CLOB variable is called a locator as it only contains the pointer/address of the CLOB.
    The CLOB itself exists in the database's temporary tablespace - and temporary LOB resource footprint in the database can be viewed via the v$temporary_lobs virtual performance view.
    Passing a CLOB pointer by reference (pointer to a pointer) does not make any sense (as would be the case if the NOCOPY clause was honoured by PL/SQL for a CLOB parameter). It is passed by value instead.
    So when you call a procedure and pass it a CLOB locator, that procedure will be dereferencing that pointer (via DBMS_LOB for example) in order to access its contents.
    Quote from Oracle® Database SecureFiles and Large Objects Developer's Guide
    >
    A LOB instance has a locator and a value. The LOB locator is a reference to where the LOB value is physically stored. The LOB value is the data stored in the LOB.
    When you use a LOB in an operation such as passing a LOB as a parameter, you are actually passing a LOB locator. For the most part, you can work with a LOB instance in your application without being concerned with the semantics of LOB locators. There is no requirement to dereference LOB locators, as is required with pointers in some programming languages.
    >
    The thing to guard against is not freeing CLOBs - the age old issue of not freeing pointers and releasing malloc'ed memory when done. In PL/SQL, there is fairly tight resource protection with the PL/SQL engine automatically releasing local resources when those go out of scope. But a CLOB (like a ref cursor) is not really a local resource. And as in most other programming language, the explicit release/freeing of such a resource is recommended.

  • String literal too long for CLOB

    Q1. I would like to insert text of 10000 chars into a column with data type CLOB via an ASP program connecting to Oracle9i. Which data type is most appropriate to input 10000 chars into a column?
    Q2. I would like to insert text UNICODE Traditional Chinese into a column with data type NCLOB, data is stored but when it is retrieved via Internet Explorer, strang chars are displayed instead of Traditional Chinese. Can any one tell me how you could store Chinese Chars, retrieve and display Chinese Chars properly in Internet Exlplorer via ASP program?

    10,000 characters is too long for a varchar2 column, but CLOB's will let you store a couple of Gb.
    When you're dealing with inserting and retrieving Traditional Chinese characters, you need to ensure that the NLS settings on your client and on your database are such that the character sets on both machines actually support the characters in question. I'm guessing that your client machine isn't configured to support those characters. If you go to http://tahiti.oracle.com and search for NLS, you'll get a boat-load of documents about how to approach this sort of problem If you haven't reviewed these yet, I'd strongly suggest doing so.
    Justin

  • Use of DISTINCT for CLOB through Java(Spring framework)

    Hello everyBody,
    How to use DISTINCT for a select query containing a column of type CLOB. I use to_char(column name) for that column name. It works fine on oracle command prompt , but not working thr my JAVA API(jdk 1.3) . It throws an exception saying InvalidFormat. I am using spring framework in Java. Is anyBody have solution to this? I am using oracle 9i. Please reply soon. Thankx in advance.

    I do realise the fact that you are using Spring probably indicates that you lack heavy duty SQL skills. But you really should try to learn to tune your queries properly.
    Cheers, APC

Maybe you are looking for

  • IPod Touch not recognized by iTunes and not charging when plugged into computer

    I plugged in my iPod touch to my Mac computer. My iPod doesn't charge and iTunes isn't recognizing it. I have turned my iPod on/off, I have reset it, I have the newest version of iTunes, and I restarted my computer. Nothing has helped. What do I do?

  • Web camera video quality in Flex

    Hi, I have a flex app which turns on a web camera and shows the video from the camera. The problem is that the video resolution is a bit choppy or pixilated. I know it's not because of the quality of the webcam since the video is very clear on other

  • Need of SAP AII

    Hello, we have already implemented WM. We want to use now RFID. During the picking (with RF), we want to put a tag on small bags. These small bags are packed in boxes that have also tag. Then the boxes are put on a pallet.We need to keep the informat

  • Simple Examples of BMP

    Hi, Does anybody have basic examples of XI BMP (Step by Step)? Thanks, Fernando

  • Audio Problem Premiere Pro-Jumps to clip start

    Hey,       i am fairly new to premiere pro and during one clip which is just over 4 minutes, the audio jumps back to the beginning and plays the beginning audio section through again and then comes back into synch at the end...          thanks for re