Using CLOB in 8.1.7

Hi,
Well, everything here seems simple with the use of CLOB. But unfortunately, it springs up a surprise,to me atleast, when compiled.
l_clob clob :=
'<?xml version = "1.0"?>
     <ROWSET>
     <ROW num="1">
     <EMPNO>7369</EMPNO>
     <ENAME>SEANDILLON</ENAME>
     <JOB>DBDUDE</JOB>
     <MGR>7902</MGR>
     <HIREDATE>12/17/1980 0:0:0</HIREDATE>
     <SAL>800</SAL>
     <DEPTNO>20</DEPTNO>
     </ROW>
     <ROW num="2">
     <EMPNO>7499</EMPNO>
     <ENAME>TOMKYTE</ENAME>
     <JOB>DBDUDE</JOB>
     <MGR>7698</MGR>
     <HIREDATE>2/20/1981 0:0:0</HIREDATE>
     <SAL>1600</SAL>
     <COMM>300</COMM>
     <DEPTNO>30</DEPTNO>
     </ROW>
     <ROW num="3">
     <EMPNO>7521</EMPNO>
     <ENAME>MICKEYMOUS</ENAME>
     <JOB>RAT</JOB>
     <MGR>7698</MGR>
     <HIREDATE>2/22/1981 0:0:0</HIREDATE>
     <SAL>1250</SAL>
     <COMM>500</COMM>
     <DEPTNO>30</DEPTNO>
     </ROW>
     </ROWSET>';
It throws the following error
PLS-00382: expression is of wrong type. What is astonishing is even if I initialize l_clob with a simple value like 'Hello World',the error persists.Can anyone please help me.

The problem is that works into a 9.2 database :
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production
SQL> declare
  2  l_clob clob :=
  3  '<?xml version = "1.0"?>
  4  <ROWSET>
  5  <ROW num="1">
  6  <EMPNO>7369</EMPNO>
  7  <ENAME>SEANDILLON</ENAME>
  8  <JOB>DBDUDE</JOB>
  9  <MGR>7902</MGR>
10  <HIREDATE>12/17/1980 0:0:0</HIREDATE>
11  <SAL>800</SAL>
12  <DEPTNO>20</DEPTNO>
13  </ROW>
14  <ROW num="2">
15  <EMPNO>7499</EMPNO>
16  <ENAME>TOMKYTE</ENAME>
17  <JOB>DBDUDE</JOB>
18  <MGR>7698</MGR>
19  <HIREDATE>2/20/1981 0:0:0</HIREDATE>
20  <SAL>1600</SAL>
21  <COMM>300</COMM>
22  <DEPTNO>30</DEPTNO>
23  </ROW>
24  <ROW num="3">
25  <EMPNO>7521</EMPNO>
26  <ENAME>MICKEYMOUS</ENAME>
27  <JOB>RAT</JOB>
28  <MGR>7698</MGR>
29  <HIREDATE>2/22/1981 0:0:0</HIREDATE>
30  <SAL>1250</SAL>
31  <COMM>500</COMM>
32  <DEPTNO>30</DEPTNO>
33  </ROW>
34  </ROWSET>';
35  begin
36  null;
37  end;
38  /
PL/SQL procedure successfully completed.
SQL> And not work onto my old 8i db like for the OP.
Connected to:
Oracle8i Enterprise Edition Release 8.1.7.4.0 - 64bit Production
With the Partitioning option
JServer Release 8.1.7.4.0 - 64bit Production
SQL> declare
  2  l_clob clob :=
  3  '<?xml version = "1.0"?>
  4  <ROWSET>
  5  <ROW num="1">
  6  <EMPNO>7369</EMPNO>
  7  <ENAME>SEANDILLON</ENAME>
  8  <JOB>DBDUDE</JOB>
  9  <MGR>7902</MGR>
10  <HIREDATE>12/17/1980 0:0:0</HIREDATE>
11  <SAL>800</SAL>
12  <DEPTNO>20</DEPTNO>
13  </ROW>
14  <ROW num="2">
15  <EMPNO>7499</EMPNO>
16  <ENAME>TOMKYTE</ENAME>
17  <JOB>DBDUDE</JOB>
18  <MGR>7698</MGR>
19  <HIREDATE>2/20/1981 0:0:0</HIREDATE>
20  <SAL>1600</SAL>
21  <COMM>300</COMM>
22  <DEPTNO>30</DEPTNO>
23  </ROW>
24  <ROW num="3">
25  <EMPNO>7521</EMPNO>
26  <ENAME>MICKEYMOUS</ENAME>
27  <JOB>RAT</JOB>
28  <MGR>7698</MGR>
29  <HIREDATE>2/22/1981 0:0:0</HIREDATE>
30  <SAL>1250</SAL>
31  <COMM>500</COMM>
32  <DEPTNO>30</DEPTNO>
33  </ROW>
34  </ROWSET>';
35  begin
36  null;
37  end;
38  /
'<?xml version = "1.0"?>
ERROR at line 3:
ORA-06550: line 3, column 1:
PLS-00382: expression is of wrong type
ORA-06550: line 2, column 8:
PL/SQL: Item ignoredNicolas.

Similar Messages

  • Opening a ref cursor using CLOB variable

    Is there any way to open a ref cusor using CLOB variable.
    When I am opening on CLOB variable , I am getting an error like 'Missing Expression'
    Please help me

    For 10g...
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    v_large_sql  CLOB;
      3    v_num        NUMBER := 0;
      4    v_upperbound NUMBER;
      5    v_sql        DBMS_SQL.VARCHAR2S;
      6    v_cur        INTEGER;
      7    v_ret        NUMBER;
      8  begin
      9    -- Build a very large SQL statement in the CLOB
    10    LOOP
    11      IF v_num = 0 THEN
    12        v_large_sql := 'CREATE VIEW vw_tmp AS SELECT ''The number of this row is : '||to_char(v_num,'fm0999999')||''' as col1 FROM DUAL';
    13      ELSE
    14        v_large_sql := v_large_sql || ' UNION ALL SELECT ''The number of this row is : '||to_char(v_num,'fm0999999')||''' as col1 FROM DUAL';
    15      END IF;
    16      v_num := v_num + 1;
    17      EXIT WHEN DBMS_LOB.GETLENGTH(v_large_sql) > 40000 OR v_num > 800;
    18    END LOOP;
    19    DBMS_OUTPUT.PUT_LINE('Length:'||DBMS_LOB.GETLENGTH(v_large_sql));
    20    DBMS_OUTPUT.PUT_LINE('Num:'||v_num);
    21    --
    22    -- Now split that large SQL statement into chunks of 256 characters and put in VARCHAR2S array
    23    v_upperbound := CEIL(DBMS_LOB.GETLENGTH(v_large_sql)/256);
    24    FOR i IN 1..v_upperbound
    25    LOOP
    26      v_sql(i) := DBMS_LOB.SUBSTR(v_large_sql
    27                                 ,256 -- amount
    28                                 ,((i-1)*256)+1 -- offset
    29                                 );
    30    END LOOP;
    31    --
    32    -- Now parse and execute the SQL statement
    33    v_cur := DBMS_SQL.OPEN_CURSOR;
    34    DBMS_SQL.PARSE(v_cur, v_sql, 1, v_upperbound, FALSE, DBMS_SQL.NATIVE);
    35    v_ret := DBMS_SQL.EXECUTE(v_cur);
    36    DBMS_OUTPUT.PUT_LINE('View Created');
    37* end;
    SQL> /
    Length:40015
    Num:548
    View Created
    PL/SQL procedure successfully completed.
    SQL> select count(*) from vw_tmp;
      COUNT(*)
           548
    SQL> select * from vw_tmp where rownum <= 10;
    COL1
    The number of this row is : 0000000
    The number of this row is : 0000001
    The number of this row is : 0000002
    The number of this row is : 0000003
    The number of this row is : 0000004
    The number of this row is : 0000005
    The number of this row is : 0000006
    The number of this row is : 0000007
    The number of this row is : 0000008
    The number of this row is : 0000009
    10 rows selected.
    SQL>

  • Using Clob with TopLink 9.0.4.5 and Oracle 10g RAC

    I am trying to store an XML file in a Clob type field of a DB table using TopLink 9.0.4.5 and Oracle 10g RAC and need some guidance about how to do it. I got some directions to start it with the Tip "How-To: Map Large Objects (LOBs) to Oracle Databases with OracleAS TopLink" but still need some more helps.
    When using the Oracle JDBC OCI driver, the tip gives the code block for a Clob field:
    DirectToField scriptMapping = new DirectToField();
    scriptMapping.setAttributeName("script");
    scriptMapping.setFieldName("IMAGE.SCRIPT");
    descriptor.addMapping(scriptMapping);
    As I understand, TopLink creates instances of the Descriptor class at run time for each of the descriptor files and stores them in a database session, where is the proper place (in SessionEvent of TopLinkSessionEventHandler?) for me to get a reference to such an instance of my Descriptor class in Java code so that I can add the above mentioned additional Mapping? Are the above String values of "script" and "IMAGE.SCRIPT" predefined in TopLink API? Can I accomplish the same thing just using the TopLink Workbench tool instead? If yes, please advise the detailed steps to do so.
    The tip also states to call the following code in case of using Clob:
    DatabaseLogin login = session.getLogin();
    login.useStringBinding();
    Should the above 2 lines of code be called after the following lines of code?
    SessionManager sessionManager = SessionManager.getManager();
    Server serverSession = (Server)sessionManager.getSession("MY_SESSION_NAME");
    Besides the above extra coding for the Session and Descriptor Mapping, is there any special handling in between Data model and DB table mapping? Can I map a Java String type to a DB Clob field using the Direct-to-field mapping?
    Appreciate any help.

    Never mind ....... I had already figured it out .....

  • Error when using CLOB

    Problem While using CLOB/BLOB datatype:
    We have created a directory in E drive and created a directory alias in oracle.
    to read the data from CLOB data type we have to write a PL/SQL code.
    But i am getting an errorin the block .ie non existent directory or file....
    ORA-22285: non-existent directory or file for FILEOPEN operation
    ORA-06512: at "SYS.DBMS_LOB", line 475
    ORA-06512: at line 8
    but the directory and file is there with all permissions.
    null

    Hi,
    Your buffer size should be the clob size.
    char[] buffer = new char[c_lob.getBufferSize()];
    Also, set the value for i as -1.
    You could see the sample on OTN for help:
    http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/advanced/LOBSample/Readme.html
    Thanks,
    Rashmi

  • EBS - 12  XMLP (5.6.3)  cannot use CLOBS  ?????

    Hello: I am being told by Metalink Support the following:
    " Bi Publisher 5.6.3 (10.1.3.2.0) does not have native support for CLOB.
    This comes in BI Publisher Enterprise 10.1.3.3.0.
    There are no plans at this time to upgrade EBS to higher versions of BI Publishe
    r code."
    So for EBS - 12, I cannot use CLOBS ?????
    How am I supposed to write reports that use large CLOBS ?
    Also, there was some mention about leaving out DataStructures in templates for CLOBS ?
    Anyone with experience in this situation, please help ...
    Yesh

    Hi Yesh,
    There is a BI (XML) Publisher Desktop for 5.6.3 that you can use, and you can use the latest versions of the desktop to build your layouts, but be aware the later versions may have more supported features not present in 5.6.3. I use 10.1.3.something for developing EBS reports and have standalone BIP Server on my desktop for checking features against.
    Data Templates are not the only way to register BIP reports in the EBS Concurrent Manager.
    You can use **any** program as long as it does actually output XML and you have set the "Output" to XML.
    The choice is up to you as to how you extract your data to XML - whatever works!
    I'm not sure what all your CLOB issues are, but creating the XML that have CLOBS shouldn't cause issues (unless you are forced by something to use dataTemplates).
    Gareth

  • Using CLOB type in AQ

    HI All
    I have AQ table and queue of object type. The object contains only one CLOB type field.
    I tried to enqueue some message using OCI functions but I got error message:
    OCI Error <25215> - ORA-25215: user_data type and queue type do not match.
    I'm using struct defined as below:
    struct message
    OCILobLocator * data;
    Does anyone know how to use CLOB object with OCI functions or maybe there is better type to enqueue hude messages??
    Thank you.

    U just have to define a rule when creating a subscriber to your queue.

  • Using CLOB data type - Pros and Cons

    Dear Gurus,
    We are designing a database that will be receiving comments from external data source. These comments are stored as CLOB in the external database. We found that only 1% of incoming data will be larger than 4000 characters and are now evaluating the Pros and Cons of storing only 4000 characters of incoming comments in VARCHAR2 data type or using CLOB data type.
    Some of the concerns brought up during discussion were:
    - having to store CLOBs in separate tablespace;
    - applications, such Toad require changing defaults settings to display CLOBs in the grid. Default value is not to display them;
    - applications that build web page with CLOBs will be struggling to fit 18 thousand chararcters of which 17 thousand are blank lines;
    - cashing CLOBs in memory will consume big chunk of data buffers which will affect performance;
    - to manipulate CLOBs you need PL/SQL anonymous block or procedure;
    - bind variables cannot be assigned CLOB value;
    - dynamic SQL cannot use CLOBs;
    - temp tables don't work very well with CLOBs;
    - fuzzy logic search on CLOBs is ineffective;
    - not all ODBC drivers support Oracle CLOBs
    - UNION, MINUS, INTERSECT don't work with CLOBs
    I have not delt with CLOB data type in the past, so I am hoping to hear from you of any possible issues/hastles we may encounter?

    848428 wrote:
    Dear Gurus,
    We are designing a database that will be receiving comments from external data source. These comments are stored as CLOB in the external database. We found that only 1% of incoming data will be larger than 4000 characters and are now evaluating the Pros and Cons of storing only 4000 characters of incoming comments in VARCHAR2 data type or using CLOB data type.
    Some of the concerns brought up during discussion were:
    - having to store CLOBs in separate tablespace;They can be stored inline too. Depends on requirements.
    - applications, such Toad require changing defaults settings to display CLOBs in the grid. Default value is not to display them;Toad is a developer tool so that shouldn't matter. What should matter is how you display the data to end users etc. but that will depend on the interface. Some can handle CLOBs and others not. Again, it depends on the requirements.
    - applications that build web page with CLOBs will be struggling to fit 18 thousand chararcters of which 17 thousand are blank lines;Why would they struggle? 18,000 characters is only around 18k in file size, that's not that big to a web page.
    - cashing CLOBs in memory will consume big chunk of data buffers which will affect performance;Who's caching them in memory? What are you planning on doing with these CLOBs? There's no real reason they should impact performance any more than anything else, but it depends on your requirements as to how you plan to use them.
    - to manipulate CLOBs you need PL/SQL anonymous block or procedure;You can manipulate CLOBs in SQL too, using the DBMS_LOB package.
    - bind variables cannot be assigned CLOB value;Are you sure?
    - dynamic SQL cannot use CLOBs;Yes it can. 11g supports CLOBs for EXECUTE IMMEDIATE statements and pre 11g you can use the DBMS_SQL package with CLOB's split into a VARCHAR2S structure.
    - temp tables don't work very well with CLOBs;What do you mean "don't work well"?
    - fuzzy logic search on CLOBs is ineffective;Seems like you're pulling information from various sources without context. Again, it depends on your requirements as to how you are going to use the CLOB's
    - not all ODBC drivers support Oracle CLOBs not all, but there are some. Again, it depends what you want to achieve.
    - UNION, MINUS, INTERSECT don't work with CLOBsTrue.
    I have not delt with CLOB data type in the past, so I am hoping to hear from you of any possible issues/hastles we may encounter?You may have more hassle if you "need" to accept more than 4000 characters and you are splitting it into seperate columns or rows, when a CLOB would do it easily.
    It seems as though you are trying to find all the negative aspects of CLOBs and ignoring all the positive aspects, and also ignoring the negative aspects of not using CLOB's.
    Without context you're assumptions are just that, assumptions, so nobody can tell you if it will be right or wrong to use them. CLOB's do have their uses, just as XMLTYPE's have their uses etc. If you're using them for the right reasons then great, but if you're ignoring them for the wrong reasons then you'll suffer.

  • Can't use clob and blob

    I just created a new database using dbca with General Purpose as the template, as I've done before. All went well until I tried to create tables that used clob or blob datatypes. I kept getting the error "ORA-03001: unimplemented feature".
    What happened? Was the database created improperly? Is there a way to correct this without recreating the database?
    Thanks

    I just created a new database using dbca with General
    Purpose as the template, as I've done before. All
    went well until I tried to create tables that used
    clob or blob datatypes. I kept getting the error
    "ORA-03001: unimplemented feature".
    I have the same problem but only if I assign a tablespace to the table but not if i leave it to the default tablespace.

  • Use CLOB & Ref Cursor

    Hi,
    Can some one help.
    I am getting string more than 32767 char so I want to use CLOB but I am unable to use in ref Cursor.
    CREATE OR REPLACE PROCEDURE PM.PROC_CURSOR_BTDCS (P_QUERY IN varchar2, P_batchid out Number) AS
    P VARCHAR2(32767);
    P_CURSOR_QUERY SYS_REFCURSOR;
    X_JOBID varchar2(30);
    X_BATCHID VARCHAR2(1000);
    X_CREF VARCHAR2(10000);
    X_CLIENTREF VARCHAR2(10000);
    X_CLIENTID NUMBER;
    X_USERID NUMBER;
    X_RDATE varchar2(40);
    X_DDATE varchar2(40);
    X_STAGE NUMBER;
    X_DIFF NUMBER;
    X_CLIENTDUEDATE varchar2(40);
    X_ASSETID NUMBER;
    X_MODEID NUMBER;
    p_o_error VARCHAR2(100);
    p_o_status NUMBER;
    BEGIN
    P := 'SELECT DISTINCT JOBID,CLID,USERID,STAGE,
    GET_CSV_DATA(CURSOR (SELECT CREF FROM ('|| P_QUERY ||') WHERE jobid =A.JOBID AND CLID=A.CLID AND USERID=A.USERID AND RDATE=A.RDATE AND DDATE=A.DDATE AND STAGE=A.STAGE AND ASSETID=A.ASSETID AND CLDATE=A.CLDATE AND DIFF=A.DIFF)) C_CREF,
    GET_CSV_DATA(CURSOR (SELECT BATCHID FROM ('|| P_QUERY ||') WHERE jobid =A.JOBID AND CLID=A.CLID AND USERID=A.USERID AND RDATE=A.RDATE AND DDATE=A.DDATE AND STAGE=A.STAGE AND ASSETID=A.ASSETID AND CLDATE=A.CLDATE AND DIFF=A.DIFF)) C_BATCH,
    GET_CSV_DATA(CURSOR (SELECT Crefname FROM ('|| P_QUERY ||') WHERE jobid =A.JOBID AND CLID=A.CLID AND USERID=A.USERID AND RDATE=A.RDATE AND DDATE=A.DDATE AND STAGE=A.STAGE AND ASSETID=A.ASSETID AND CLDATE=A.CLDATE AND DIFF=A.DIFF)) C_CLIENTREF
    ,DIFF,cldate,ASSETID
    ,RDATE,DDATE,MODEID
    FROM('||P_QUERY||') A';
    --INSERT INTO FROG VALUES(P,sysdate);
    OPEN P_CURSOR_QUERY FOR P;
    LOOP
    FETCH P_CURSOR_QUERY INTO X_JOBID
    ,X_CLIENTID,X_USERID,X_STAGE,
    X_CREF,X_BATCHID,X_CLIENTREF,X_DIFF,
    X_CLIENTDUEDATE,
    X_assetid,X_RDATE,X_DDATE,X_MODEID;
    EXIT WHEN P_CURSOR_QUERY%NOTFOUND;
    -- INSERT INTO FROG VALUES (X_CREF);
    Proc_batchchangestage_upd (X_JOBID,X_BATCHID,X_CREF,X_CLIENTREF,X_userid,X_clientid,X_RDATE,
    X_DDATE,
    X_stage,
    X_CLIENTDUEDATE,
    X_diff,
    X_assetid,X_MODEID,p_batchid,
    p_o_error,
    p_o_status);
    END LOOP;
    CLOSE P_CURSOR_QUERY;
    COMMIT;
    END;

    It would be helpful to indicate the error you're getting and the line where you're getting the error.
    I will assume that your goal is to construct a SQL query > 32k, store that query in p, and open a cursor using p. In order to do that, you'd have to use the DBMS_SQL package, which is going to complicate your life rather significantly.
    That said, it's far from obvious to my why the SQL statement needs to exceed 32k. At a minimum, concatentaing P_QUERY three times would seem unnecessary. If the text of P_QUERY exceeds 10,000 characters, I would really tend to suspect that you've done something wrong there and would benefit from simplifying the query or at least using a couple views.
    Justin

  • How to use clob or blob data type in OWB

    how to use clob or blob data type in OWB?
    if OWB not surport these data type,how can i extract the large data type from data source

    The same question was asked just two days ago No Data Found: ORA-22992
    Nikolai Rochnik

  • How to use CLOB

    When I use CLOB like
    CREATE OR REPLACE PROCEDURE Example_1b(retData out clob) IS
    src_lob cLOB;
    BEGIN
    SELECT b_lob INTO src_lob
    FROM lob_table
    DBMS_LOB.APPEND(dest_lob, src_lob);
    COMMIT;
    EXCEPTION
    WHEN some_exception
    THEN handle_exception;
    END;
    There are thousand records in lob_table.When I run the procedure,It's very very slowwer !
    How to improve it?

    I assume there are some lines missing here.
    >
    1 CREATE OR REPLACE PROCEDURE Example_1b(retData out clob) IS
    2 src_lob cLOB;
    3 BEGIN
    4 SELECT b_lob INTO src_lob
    5 FROM lob_table
    6 DBMS_LOB.APPEND(dest_lob, src_lob);
    7 COMMIT;
    8 EXCEPTION
    9 WHEN some_exception
    10 THEN handle_exception;
    11 END;
    [unquote]
    Is there a where clause missing after line 5 or is it your intent to select your whole clob table? If it is, then you should use a curser like so:
    >
    1 CREATE OR REPLACE PROCEDURE Example_1b(retData out clob) IS
    2 CURSOR c1 is SELECT b_lob
    3 FROM lob_table;
    4
    5 src_lob cLOB;
    6 BEGIN
    7 for src_lob in c1 loop
    6 DBMS_LOB.APPEND(dest_lob, src_lob);
    7 end loop;
    8 EXCEPTION
    9 WHEN some_exception
    10 THEN handle_exception;
    11 END;
    [unquote]
    Please note, I removed the commit at line 7 as it was unecessary in your procedure (you showed no inserts, updates, or deletes).

  • How to store a large document in Oracle9i using CLOB!?

    Hi all,
    I want to store a large document(about 10mb) in Oracle9i using SQL*PLUS. How to store it using CLOB in Oracle9i!?
    What the necessary steps to perform!?
    Thanks

    Just use the report's CUID or ID for the iDocID parameter, and give all necessary users the appropriate rights to the inbox where the report is located.
    repoType is a legacy parameter, this will have no effect.
    http://help.sap.com/businessobject/product_guides/boexir31/en/xi3-1_url_reporting_opendocument_en.pdf

  • Keep getting string literal when using CLOBs

    Hi, I am using Oracle 11.2.0.3 on Windows 2003 R2 and I have a procedure to extract various bits of XML and GML from an XMLType column. The GML for a record can be one or more geometries and I need to derive a single SDO_GEOMETRY from and convert to WGS84. I created a function called MULTI_GML_TO_SDOGEOM in which I parse my GML as a CLOB. I then add it to a SQL_STMT variable which is also a CLOB. In processing 10,000 records, this function worked fine for 8000 but then failed when it hit a record that had over 4000 characters in the GML (seven geometries) with a ORA-01704 string literal too long. I entered debug on every line of the function and found the function failed on the open cursor statement
    OPEN c_geoms FOR sql_stmt;I can't understand why I am getting this error as the total length of sql_stmt for the record that failed was about 7500 characters and I am using CLOBs which should be able handle that length. I am not sure if I have not used the CLOBs correctly or perhaps I need to use something from DBMS_LOB package but I cannot find any decent examples and I am not really sure why this doesn't work anyway.
    Here is the function:
    CREATE OR REPLACE FUNCTION MULTI_GML_TO_SDOGEOM (
       geometry_components IN CLOB)
       RETURN sdo_geometry
    IS
    v_count             NUMBER;
    v_gml               XMLType;
    v_gml_rec           XMLType;
    v_gml_clob          CLOB;
    v_gml_clob_rec      CLOB;
    sql_stmt            CLOB;
    v_sdogeom           SDO_GEOMETRY;
    v_sdogeom_all       SDO_GEOMETRY;
    varray_sdogeom      SDO_GEOMETRY_ARRAY;
    TYPE t_ref_cursor  IS REF CURSOR;
    c_geoms         t_ref_cursor;
    BEGIN
    varray_sdogeom := SDO_GEOMETRY_ARRAY();
    IF geometry_components is not null THEN
      v_gml := XMLType ('<GeometryComponents xmlns:gml="http://www.opengis.net/gml/3.2">'||geometry_components||'</GeometryComponents>');
      v_gml_clob := v_gml.getClobVal();
      SELECT count(*) INTO v_count FROM XMLTable ('declare namespace gml="http://www.opengis.net/gml/3.2"; (: :)
                                                 //polygon' PASSING v_gml);
      If v_count > 0 THEN
        sql_stmt := 'WITH gml_input AS (SELECT XMLType ('''||v_gml_clob||''') as gmldata from dual)
                     select poly.spatial_location from gml_input,
                                                     xmltable (xmlnamespaces (''http://www.opengis.net/gml/3.2'' as "gml"),
                                                              ''GeometryComponents/polygon/gml:Polygon''
                                                               PASSING gmldata
                                                               COLUMNS
                                                               spatial_location XMLTYPE PATH ''//gml:Polygon'') poly
                     UNION ALL
                     select point.spatial_location from gml_input,
                                                     xmltable (xmlnamespaces (''http://www.opengis.net/gml/3.2'' as "gml"),
                                                              ''GeometryComponents/polygon/gml:Point''
                                                               PASSING gmldata
                                                               COLUMNS
                                                               spatial_location XMLTYPE PATH ''//gml:Point'') point';
    --    dbms_output.put_line (sql_stmt);
        OPEN c_geoms FOR sql_stmt;
        LOOP
          FETCH c_geoms INTO v_gml_rec;
          EXIT WHEN c_geoms%NOTFOUND;
          v_gml_clob_rec := v_gml_rec.getClobVal;
          sql_stmt := 'SELECT SDO_CS.TRANSFORM(SDO_UTIL.FROM_GML311GEOMETRY ('''||v_gml_clob_rec||'''), 8307) FROM dual';
          EXECUTE IMMEDIATE sql_stmt INTO v_sdogeom;
          varray_sdogeom.EXTEND;
          varray_sdogeom(varray_sdogeom.COUNT) := v_sdogeom;
        END LOOP;   -- c_geoms fetch
        CLOSE c_geoms;
        select SDO_AGGR_SET_UNION(varray_sdogeom, 0.005) INTO v_sdogeom_all from dual;
      END IF;  -- v_count > 0
    RETURN v_sdogeom_all;
    END IF;
    END MULTI_GML_TO_SDOGEOM;
    show errorsUnfortunately I cannot add the data I am processing as it is classified but here is a dummy sample of the type of GML I am parsing though this is short enough that it works:
    <GeometryComponents xmlns:gml="http://www.opengis.net/gml/3.2">
    <polygon xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:srv="http://www.isotc211.org/2005/srv"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:mgmp="http://www.mod.uk/mgmp" xmlns:smr="http://www.mod.uk/smr"
    xmlns:xlink="http://www.w3.org/1999/xlink"><gml:Polygon gml:id="bp2" srsName="EPSG:4326">
    <gml:exterior>
    <gml:LinearRing>
    <gml:posList srsDimension="2">175 -40 176 -40 176 -39 175 -39 175 -40</gml:posList>
    </gml:LinearRing>
    </gml:exterior>
    </gml:Polygon>
    </polygon>
    </GeometryComponents>And although this function is normally called from a procedure, here is a call from dual
    select MULTI_GML_TO_SDOGEOM ('<GeometryComponents xmlns:gml="http://www.opengis.net/gml/3.2">
    <polygon xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:srv="http://www.isotc211.org/2005/srv"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:mgmp="http://www.mod.uk/mgmp" xmlns:smr="http://www.mod.uk/smr"
    xmlns:xlink="http://www.w3.org/1999/xlink"><gml:Polygon gml:id="bp2" srsName="EPSG:4326">
    <gml:exterior>
    <gml:LinearRing>
    <gml:posList srsDimension="2">175 -40 176 -40 176 -39 175 -39 175 -40</gml:posList>
    </gml:LinearRing>
    </gml:exterior>
    </gml:Polygon>
    </polygon>
    </GeometryComponents>') from dual;Thanks in advance.

    Hi,
    I fail to see why you use dynamic SQL here.
    As said above, you're doing a lot of bad and unnecessary stuff, first of which being not using bind variables.
    Then I see a lot serializing/constructing on XMLType which just adds more overhead.
    Basically, the function can be simplified down to :
    create or replace function multi_gml_to_sdogeom (
      geometry_components in clob
    return sdo_geometry
    is
      v_sdogeom_all       SDO_GEOMETRY;
    begin
      select SDO_AGGR_SET_UNION(
               cast(
                 collect(
                   SDO_CS.TRANSFORM(SDO_UTIL.FROM_GML311GEOMETRY(spatial_location), 8307)
                 as sdo_geometry_array
             , .005
      into v_sdogeom_all
      from (
        select xmlserialize(content x.column_value) as spatial_location
        from xmltable(
               xmlnamespaces ('http://www.opengis.net/gml/3.2' as "gml")
             , '/GeometryComponents/polygon/(gml:Polygon|gml:Point)'
               passing xmlparse(document geometry_components)
             ) x
      return v_sdogeom_all;
    end;
    SQL> select multi_gml_to_sdogeom('<GeometryComponents xmlns:gml="http://www.opengis.net/gml/3.2">
      2  <polygon xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:srv="http://www.isotc211.org/2005/srv"
      3  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:mgmp="http://www.mod.uk/mgmp" xmlns:smr="http://www.mod.uk/smr"
      4  xmlns:xlink="http://www.w3.org/1999/xlink"><gml:Polygon gml:id="bp2" srsName="EPSG:4326">
      5  <gml:exterior>
      6  <gml:LinearRing>
      7  <gml:posList srsDimension="2">175 -40 176 -40 176 -39 175 -39 175 -40</gml:posList>
      8  </gml:LinearRing>
      9  </gml:exterior>
    10  </gml:Polygon>
    11  <gml:Point gml:id="p21" srsName="EPSG:4326">
    12      <gml:coordinates>45.67, 88.56</gml:coordinates>
    13    </gml:Point>
    14  </polygon>
    15  </GeometryComponents>')
    16  from dual ;
    MULTI_GML_TO_SDOGEOM('<GEOMETR
    <Object>
    Edited by: odie_63 on 8 janv. 2013 18:02

  • Using CLOBs in oracle Report Builder

    I want to select all the data in a CLOB column using SQL Navigator by just doing
    select entry_note
    from chartentries;
    just as you say in your example by it just gives me back a result of (ORACLOB).
    If I do
    select to_char(entry_note)
    from chartentries;
    I get this error.
    If I do
    select dbms_lob.substr(entry_note,4000,1)
    from chartentries
    I get this (there’s more up to 32000 characters in a clob) and these weird squares which I think are CR (carriage returns) or LF (line feeds). I don’t want to see those characters and I would like to retrieve the entire CLOB in one swoop without doing data manipulations of substringing.
    Using the same data in Oracle Report Builder, I want to select all the data in a CLOB column into a field in a Paper report layout but I keep getting errors, ora-6502, and I've found out that I am restricted to 4000 characters and in Report 9i it looks like the largest field you can have is 4000 characters. My CLOB information can be up to 32000 characters long or longer and I do not want to substring out 4000 characters at a time into separate fields. In Crystal reports there is no problem just selecting the clob in a simple query and it is there in one shot. I would have thought by now that Oracle would have changed its development tools to be able to handle Clobs simply without any manipulation. Does anyone know how to do this in Report builder? I just have a simple query:
    select entry_datetime,
    to_char(replace((entry_note),chr(13))) as entry_note
    from chartentries
    where patient_id = 49741
    Another thing I want to do, is call this Oracle report from a PL/SQL block passing several parameters to the report and also call a Crystal report from a PL/SQL block passing several parameters to the report. Does anyone know what the commands are?

    What I had to do is create a query using query builder. This works fine; it's when trying to add the column to an existing query is where the data inconstancy error occurs. One thing you have to keep in mind is it will only work using the query builder in conjunction with the report wizard; I am not sure why. To incorporate the comments into an existing frame you will have to cut the frame created by the wizards and copy it into the existing frame. Otherwise the column name will not show in the source list of the property Inspector.
    Good Luck

  • Problem in using CLOB Data from a Data and exporting into File

    Hi,
    UTL_FILE Error Occured while using UTL_FILE with CLOB Data.
    UTL_FILE: A write error occurred.
    The Below Code is for reference:
    DECLARE
    C_AMOUNT CONSTANT BINARY_INTEGER := 32767;
    L_BUFFER VARCHAR2(32767);
    L_CHR10 PLS_INTEGER;
    L_CLOBLEN PLS_INTEGER;
    L_FHANDLER UTL_FILE.FILE_TYPE;
    L_POS PLS_INTEGER := 1;
    BEGIN
         FILE_NAME:=UTL_FILE.FOPEN('EXPORT_DIR','EXPORT_FILE'||'.sql','W');
         FOR C1_EXP IN (SELECT INSERT_STRING FROM EXPORTED_DUMP) LOOP
         L_CLOBLEN := DBMS_LOB.GETLENGTH(C1_EXP.INSERT_STRING);
         DBMS_OUTPUT.PUT_LINE('THE CLOB LEN '||L_CLOBLEN);
         DBMS_OUTPUT.PUT_LINE('THE POSITION '||L_POS);
         WHILE L_POS < L_CLOBLEN LOOP
    L_BUFFER := DBMS_LOB.SUBSTR(C1_EXP.INSERT_STRING, C_AMOUNT, L_POS);
         DBMS_OUTPUT.PUT_LINE('THE BUFFER IS '||L_BUFFER);
    EXIT WHEN L_BUFFER IS NULL;
    UTL_FILE.PUT_LINE(FILE_NAME, C1_EXP.INSERT_STRING);
    L_POS := L_POS + LEAST(LENGTH(L_BUFFER)+1,c_amount);
    END LOOP;
         END LOOP;
    UTL_FILE.FCLOSE(FILE_NAME);
    EXCEPTION
    WHEN UTL_FILE.INTERNAL_ERROR THEN
    DBMS_OUTPUT.PUT_LINE ('UTL_FILE: An internal error occurred.');
    UTL_FILE.FCLOSE_ALL;
    WHEN UTL_FILE.INVALID_FILEHANDLE THEN
    DBMS_OUTPUT.PUT_LINE ('UTL_FILE: The file handle was invalid.');
    UTL_FILE.FCLOSE_ALL;
    WHEN UTL_FILE.INVALID_MODE THEN
    DBMS_OUTPUT.PUT_LINE ('UTL_FILE: An invalid open mode was given.');
    UTL_FILE.FCLOSE_ALL;
    WHEN UTL_FILE.INVALID_OPERATION THEN
    DBMS_OUTPUT.PUT_LINE ('UTL_FILE: An invalid operation was attempted.');
    UTL_FILE.FCLOSE_ALL;
    WHEN UTL_FILE.INVALID_PATH THEN
    DBMS_OUTPUT.PUT_LINE ('UTL_FILE: An invalid path was give for the file.');
    UTL_FILE.FCLOSE_ALL;
    WHEN UTL_FILE.READ_ERROR THEN
    DBMS_OUTPUT.PUT_LINE ('UTL_FILE: A read error occurred.');
    UTL_FILE.FCLOSE_ALL;
    WHEN UTL_FILE.WRITE_ERROR THEN
    DBMS_OUTPUT.PUT_LINE ('UTL_FILE: A write error occurred.');
    UTL_FILE.FCLOSE_ALL;
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE ('Some other error occurred.');
    UTL_FILE.FCLOSE_ALL;
    END;

    Hi user598986!
    OK, I understood that there is a problem with your code. But please would you be so kindly to tell us here what error exactly happens (the errormessage). Mabay after that someone will be able to help you.
    yours sincerely
    Florian W.
    P.S. If you enclose your code into tags it will be shown formated.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Using clobs and ORA-01704: string literal too long

    Hi,
    I am attempting to add oracle support to an existing J2ee application. The issue I am facing is the use of CLOB datatypes and the 4k string literal limitation that Oracle has.
    I have dowloaded the 10.2.0.3 thin driver and am connected to a 9i release 2 database. When I execute a statement such as the following (say the table has one varchar2 field and two clob fields
    Insert into my_table VALUES ('hi','something','pretend this string is 5000 characters')
    I still receive the error
    java.sql.SQLException: ORA-01704: string literal too long
    I have read that the version 10 drivers were supposed to address this limitation. Is there something I am missing or must I change my home grown database layer to use bind variables or clob manipulation in a separate update/insert statement.? I am trying to avoid this situation since the database layer works fine for the situation of MSSQL and text fields which have no such limitation.
    Any advice you have here is greatly appreciated.
    Thanks,
    Joe

    Hi,
    I am attempting to add oracle support to an existing J2ee application. The issue I am facing is the use of CLOB datatypes and the 4k string literal limitation that Oracle has.
    I have dowloaded the 10.2.0.3 thin driver and am connected to a 9i release 2 database. When I execute a statement such as the following (say the table has one varchar2 field and two clob fields
    Insert into my_table VALUES ('hi','something','pretend this string is 5000 characters')
    I still receive the error
    java.sql.SQLException: ORA-01704: string literal too long
    I have read that the version 10 drivers were supposed to address this limitation. Is there something I am missing or must I change my home grown database layer to use bind variables or clob manipulation in a separate update/insert statement.? I am trying to avoid this situation since the database layer works fine for the situation of MSSQL and text fields which have no such limitation.
    Any advice you have here is greatly appreciated.
    Thanks,
    Joe

Maybe you are looking for