Clob vs distinct

Hi all,
For different reasons, I need to include a clob column in a distinct clause on my query but, it seems impossible. I always have a format error. If I don't use the distinct clause, the query runs ok.
How can I include this clob in?
Regards,
dbajug

You can't
http://download.oracle.com/docs/cd/E11882_01/server.112/e10592/statements_10002.htm#sthref6729
You cannot specify DISTINCT if the select_list contains LOB columns.

Similar Messages

  • 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

  • How to get distinct on CLOB

    Hi,
    I have a table with one of the column as CLOB,My requirement is as below.
    1)Get distinct data to eliminate the duplicate records from the load (Which includes CLOB column too)
    2)Need to compare the old data in the table with incoming source data .
    Both these cases I need to deal with CLOB objects which made my life difficult.
    Can some one suggest an appropriate solution,as ,how to handle the scenario as well CLOB objects in these kind of scenarioes.
    Thanks in advance,
    Rajesh.

    Hi,
    Is this what you require??
    SQL> create table testclob
      2  (id number,
      3  data clob);
    Table created.
    SQL> insert into testclob values(1,'Oracle SQL tecnology');
    1 row created.
    SQL> insert into testclob values(2,'Oracle PL/SQL tecnology');
    1 row created.
    SQL> insert into testclob values(3,'Oracle SQL tecnology');
    1 row created.
    SQL> insert into testclob values(4,'Oracle SQL tecnology');
    1 row created.
    SQL> insert into testclob values(5,'Oracle PL/SQL tecnology');
    1 row created.
    SQL> insert into testclob values(6,'JAVA tecnology');
    1 row created.
    SQL> insert into testclob values(7,'SIEBEL  tecnology');
    1 row created.
    SQL> insert into testclob values(8,'Oracle Forms tecnology');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> set lines 900
    SQL> select * from testclob;
            ID DATA
             1 Oracle SQL tecnology
             2 Oracle PL/SQL tecnology
             3 Oracle SQL tecnology
             4 Oracle SQL tecnology
             5 Oracle PL/SQL tecnology
             6 JAVA tecnology
             7 SIEBEL  tecnology
             8 Oracle Forms tecnology
    8 rows selected.
    SQL> select distinct data from testclob;
    select distinct data from testclob
    ERROR at line 1:
    ORA-00932: inconsistent datatypes: expected - got CLOB
    SQL>  select distinct to_char(data) from testclob;
    TO_CHAR(DATA)
    Oracle SQL tecnology
    Oracle PL/SQL tecnology
    SIEBEL  tecnology
    JAVA tecnology
    Oracle Forms tecnologyTwinkle

  • How to find out list of clob/blob tables in a schema

    Hi,
    I have tricky situation...i have 119 tables out of which 11 tables are clob/blob tables...is there any view where i can find out list of tables are clob/blob tables? (at schema level view means user_<>)
    -- Raman.

    USER_TAB_COLS includes the data type, column name, and table name for each column in each table in the system. You could query that looking for columns with a DATA_TYPE of CLOB or BLOB. If some tables have multiple LOB columns and you want them to appear only once, you'd have to throw a DISTINCT on the table name.
    Justin

  • Select with CLOB datatype

    Hi all....
    I must create a view to retrieve the data from a table "texto_email" ... and that table has a field named Texto - datatype CLOB. This field has some html definitions and formating tags.
    but when i create the view, i get a error in plsql saying "view created with compilation errors"
    when i coment " -- " the line responsable for the CLOB field, its created sucesful.
    what I´m doing wrong? there´s a something diferent to do in this case?
    that is my view... if someone can help...
    CREATE OR REPLACE FORCE VIEW vw_texto_email
    AS
    SELECT DISTINCT
    te.id_texto_email
    ,te.id_texto_email_tipo as id_tet
    ,te.data_cadastro
    ,te.data_inicio
    ,te.descricao
    ,te.assunto
    ,te.texto AS texto ---- that is the CLOB field -
    ,tet.descricao as tipo_email
    FROM
    texto_email te
    ,texto_email_tipo tet
    WHERE
    te.id_texto_email_tipo = tet.id_texto_email_tipo
    tnks....

    To work with LOBs you have to know something about the concept of a LOB locator( a short tour in the documentation would be appreciable).
    A LOB locator is a pointer to large object data in a database.
    Database LOB columns store LOB locators, and those locators point to the real data stored in a LOB data.
    To work with LOB data, you have to:
    1) Retrieve LOB locator
    2) Use a built-in package named DBMS_LOB to modify LOB
    2.1 Open lob
    2.2 ...
    2.3 read/write LOB
    2.4 close LOB
    Why do you want to retrieve a lob locator in a view?
    Stated that you could retreive its state in :
    1 null
    2 empty
    3 populated with a valid pointer to data

  • Getting all occurrences from a clob field

    I created a clob field to store an XML document. I have tried the SUBSTR, INSTR, REGEXP_SUBSTR, DBMS_LOB.INSTR functions to extract all occurrence of the XML tab <systemLink>.
    I just get 1 occurrence of the XML tag.
    Has anyone done this before.
    Thanks.

    All occurrences in a single row
    select extract(xmltype(your_clob_field),'//systemLink')
    from dualOr all occurrences in distinct rows
    select *
    from TABLE (XMLSEQUENCE (EXTRACT (XMLTYPE (your_clob_field), '//systemLink'))) ; Max
    http://oracleitalia.wordpress.com

  • How to get a distinct count of multiple columns

    I've done this before and I'll be darned why I can't recall this.
    Table with 3 columns with the primary key defined in column a.
    Row a b c
    num.
    1 020 how abc
    2 030 why def
    3 010 not ghi
    4 040 how abc
    5 050 yes def
    6 060 why def
    So what I want is a count of the unique values for columns b and c as if b and c were actually one field.
    So the result of the query would be:
    Count = 4 unique rows.
    Hopefully I'm making some sort of sense. It's a bit much to ask about the number of occurrences of each duplicate value, I'm sure just getting count of the unique rows of the non-indexed rows will be sufficient. Since the query is meant to be universal for multiple columns of numeric and alphanumeric data and can be expanded for multiple columns, I am simply trying to get a basic skeleton that works for an "on the fly" analysis.

    Thanks to all of you. I had the idea and just couldn't nail it down. You did it.
    All of you understood what I poorly communicated. My apologies for the lack of prep with a table, I was running patches on the system and couldn't dare interrupt it on my laptop and starting Oracle 11 while Micro$lop was patching all sorts of evil code. This is something I'm setting up on my own time so it's a work I'm going to try to be proud of. So there will be plenty of instrumentation and debugging code for timing.
    I'd thought of concatenating columns and was worried it wouldn't backport to older Oracle versions (work goes back to 8.1.7) with nulls and other goofy things like long raw fields or lob/clobs plus the other DBs that are at various sites. What I'm trying to do is improve on a crappy data analysis tool SAP provides to use with reporting unique columns. (Basis people could recognize this as DB05). I tried dragging out the SQL that their ABAP/4 language generates from an SQL trace but it was unusable and often dies on internal storage which on most sites is about 4GB per process. Needless to say, the program is wasteful and I'm trying to keep the work on the DB where it belongs and discourage cowboys from doing this in the DB on the fly and at the same time make it simpler for junior members to use while having a semblance of an audit trail.
    What I'm trying to do is work out a tool that checks all the crappy secondary indexes that were created by folks who seem to think in ways that are from an alien species not yet speculated about even with the strongest psychedelics. One of them actually decreases performance by a minimum factor of 5. It's not much when it's 5 seconds but when the response time averages about 3 hours beforehand, you can imagine what it was like afterward. In this particular case, the "logic" was that the index needed to be defined by the order of the fields of the select clause. Some myths never die. So it's not easy to work out which ones haven't been used in a long time, so it's down to finding which of the custom ones are actually bad in terms of selectivity. Some of these may have made a little bit of sense when the system was started up, now that some of these have millions of rows instead of a few thousand, thaw tend to expose the flaws in design.
    I'm also trying to make this work on multiple DBs such as DB2, MaxDB and (sob) SQL Squealer. The idea is to write this in ABAP code as a utility without the overhead of internal tables in ABAP as some of these tables are many millions of rows and I have to account for the size in memory. (ABAP field sizes in internal memory are generally much larger than the actual DB lengths. so every bit helps!) So I'm trying to create actual SQL on the fly and use it internally without going through the SAP DB interface which limits the type of SQL functions used and all the overhead. It's intended to grab a secondary index and if there are more than 2 fields defined, work it backwards to show unique values for all columns, all columns - 1, all columns - 2 and so on back to the initial column in the index.
    Why does this seem important? On Oracle I can generate histograms but those can often screw up SAP. On other DBs, the indexing cardinality is much more important, particularly with DB optimizers that make some odd decisions. So I need evidence I can push to folks who will only understand if there's a plain and simple analysis that explains it (almost) in crayon.
    I'm testing null values next (which worked!) but these suggestions all seem to follow the same idea which won't work in ABAP without some serious memory issues. So I'm down to this type of coding:
    exec sql.
    <dynamically generated true SQL>
    end-exec.
    rather than using ABAP with their concept of "open SQL" and the DB interface with all the overhead.
    RB's suggestion of the UNION ALL wasn't quite what I was looking for BUT it made me think that this would be a nice enhancement for evaluations!
    So the candidates that seem to work for what I wanted are as follows:
    SQL> SELECT COUNT (MIN (0)) AS distinct_col3_col4_cnt
    2 from rb group by b, c;
    DISTINCT_COL3_COL4_CNT
    7
    select count(distinct(b || c)) num_rows from rb;
    So thanks also to Frank, APNL and Nimesh for their examples. Now the fun starts as I spec out the processing.

  • Failed to convert Clob to String by using dbms_lob.substr

    it says that the cache is not enough to do this.
    I would like to get some infos from two tables as a View.
    and one of the table contains a Clob data which is large
    than 4k i think.
    and when I tried to create the view, it says that expecting
    - but got Clob, so I would like to change it to String by using
    dbmas_lob.substr function and met the cache limited problem.
    The database I am using is 10.2.0.1.0.

    Thanks for reply.
    and the problem was fixed.
    after I removed 'distinct', which specified after 'select'.

  • Clob mapping not working with mysql

    Hi,
    I have an application that i'm running with MySQL and Oracle at the same
    time. At some point, i need to use a 'clob' mapping. When i do this, it
    just works fine with oracle but it fails with mysql. i have the exception:
    Field "com.ennov.prisma.api.document.jdo.AbstractDocumentPO.description"
    is mapped as a clob, but should be represented as a different mapping.
    If the field is a string and you would like to force it to map as a
    clob, add an extension to its field metadata with a key of "jdbc-size"
    and a value of
    -1.[com.ennov.prisma.api.document.jdo.AbstractDocumentPO.description]
         at kodo.jdbc.meta.Mappings.invalidMapping(Mappings.java:132)
         at kodo.jdbc.meta.Mappings.invalidMapping(Mappings.java:118)
         at
    kodo.jdbc.meta.ClobFieldMapping.fromMappingInfo(ClobFieldMapping.java:46)
    if i use a value mapping, it works with MySQL but fails with Oracle (I
    have sql error because a clob is used in a distinct select).
    In the manual, it is written "Note that some databases can support
    string of unlimited length without using a CLOB; when this is the case
    the mapping tool will install a value mapping in favor of
    this mapping.". So apparently, this is not the case with MySQLDictionary.
    To solve my problem and have my code working with both databases, i had
    to extend the MySQLDictionary and overwrite the replaceFieldMapping
    method in order to replace the clob mapping by a value mapping at
    runtime but i don't feel confident to do this kind of modifications by
    mysel and would expect this behaviour to be solved quite soon.
    Thanks for your help since this problem is urgent for us,
    Laurent Czinczenheim

    Laurent-
    The best solution would probably be to just have separate mappings for
    the MySQL and Oracle databases. The easiest way to accomplish this would
    be to have a separate setting for each of the databases. E.g.:
    kodo.jdbc.meta.MappingFactory: file(SingleFile=true, FileName=oracle.mapping)
    kodo.jdbc.meta.MappingFactory: file(SingleFile=true, FileName=mysql.mapping)
    That way, you can use a clob mapping for Oracle, and a normal value
    mapping for MySQL (since MySQL doesn't need to use the CLOB mapping, and
    it isn't very efficient).
    For more details on this, see:
    http://docs.solarmetric.com/manual.html#ref_guide_mapping_factory
    Another solution is to just stick with your custom extension of the
    MySQLDictionary, which is a perfectly valid way of having special CLOB
    handling in MySQL. Note, though, that CLOB handling is less efficient
    than VARCHAR handling, so it should be a mapping of last resort, and
    there isn't any need to use it in MySQL.
    In article <[email protected]>, czinczenheim wrote:
    Hi,
    I have an application that i'm running with MySQL and Oracle at the same
    time. At some point, i need to use a 'clob' mapping. When i do this, it
    just works fine with oracle but it fails with mysql. i have the exception:
    Field "com.ennov.prisma.api.document.jdo.AbstractDocumentPO.description"
    is mapped as a clob, but should be represented as a different mapping.
    If the field is a string and you would like to force it to map as a
    clob, add an extension to its field metadata with a key of "jdbc-size"
    and a value of
    -1.[com.ennov.prisma.api.document.jdo.AbstractDocumentPO.description]
         at kodo.jdbc.meta.Mappings.invalidMapping(Mappings.java:132)
         at kodo.jdbc.meta.Mappings.invalidMapping(Mappings.java:118)
         at
    kodo.jdbc.meta.ClobFieldMapping.fromMappingInfo(ClobFieldMapping.java:46)
    if i use a value mapping, it works with MySQL but fails with Oracle (I
    have sql error because a clob is used in a distinct select).
    In the manual, it is written "Note that some databases can support
    string of unlimited length without using a CLOB; when this is the case
    the mapping tool will install a value mapping in favor of
    this mapping.". So apparently, this is not the case with MySQLDictionary.
    To solve my problem and have my code working with both databases, i had
    to extend the MySQLDictionary and overwrite the replaceFieldMapping
    method in order to replace the clob mapping by a value mapping at
    runtime but i don't feel confident to do this kind of modifications by
    mysel and would expect this behaviour to be solved quite soon.
    Thanks for your help since this problem is urgent for us,
    Laurent Czinczenheim
    Marc Prud'hommeaux
    SolarMetric Inc.

  • How to find distinct words in Oracle Text index

    We have a requirement to fetch all distinct words in the CLOB field for all records
    and find the no. of records in which each word appears.
    DR$<Index Name>$I table stores exactly such information. Is it ok to use this table in queries?
    Are there any disadvantages in using it?
    Help is very much appreciated.

    the disadv -
    with every sync index the contents will change.
    with every release the structure may change without any prior information - your application may go bad.
    It is not advisable to use them in your applications. For your own investigation etc you can always use its contents.
    thanks

  • SELECT DISTINCT With OPEN cursor FOR

    Hello.
    I have the following procedure. All it does is open a cursor for an SQL string passed into it, and return the open cursor.
    PROCEDURE sp_execute_dynamic (hold_input_string IN CLOB,
    hold_cursor OUT hold_cursor_type) IS
    BEGIN
    OPEN hold_cursor FOR TO_CHAR(hold_input_string);
    END sp_execute_dynamic;
    It works fine except when I perform SELECT DISTINCT. I get the following error.
    SQL> declare
    2 TYPE hold_cursor_type IS REF CURSOR;
    3 hold_cursor hold_cursor_type;
    4 hold_object_name VARCHAR2(1024);
    5 hold_object_type VARCHAR2(1024);
    6 begin
    7 dynamic_sql_pkg.sp_execute_dynamic('select distinct object_name from user_objects where object_
    name in (''PLAN_TABLE'',''DBA_OBJECTS'')',hold_cursor);
    8 loop
    9 fetch hold_cursor into hold_object_name, hold_object_type;
    10 exit when hold_cursor%NOTFOUND;
    11 dbms_output.put_line('Object Name = '||hold_object_name||' Object Type = '||hold_object_type);
    12 end loop;
    13 end;
    14 /
    declare
    ERROR at line 1:
    ORA-01007: variable not in select list
    ORA-06512: at line 9
    It does the same thing with SELECT UNIQUE or SELECT with a GROUP BY. Can anyone tell me why this happens and what I could to to work around it?
    Thanks
    Chris

    see at line 7 you are selecting only one column and at line 9you are fetching into two variables
    7 dynamic_sql_pkg.sp_execute_dynamic('select distinct object_name from user_objects where object_
    name in (''PLAN_TABLE'',''DBA_OBJECTS'')',hold_cursor);
    8 loop
    9 fetch hold_cursor into hold_object_name, hold_object_type;
    HTH

  • 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

  • Function based indexes on CLOB storage

    On a 10gR2 database, with schema-less CLOB storage for an XMLType column:
    (1) Can a function based index include a wildcard in the namespace ? Or do I need a new function based index for each specific namespace ?
    (2) I must create a new function based index for each different element that I want an indexed search on ?
    (3) What limit is there on the number of function based indexes per table ?
    (4) I believe XQuery can include a wildcard for namespaces, but XPath 1.x can't. Can I create a function based index using XQuery, rather than XPath ?
    Documents conforming to different versions of an XML schema will be present (schema versioning), but I want to search across all documents irrespective of a specific namespace - e.g. "Find any document with reference = 'some Value' , and amount = 1000".
    CLOB storage is proposed, due to the need to handle documents from multiple versions of an XML schema. The knowledge of the XSD is not known at development time, but is user definable, and it must be possible to change the structure without system down time. Structured storage is not suitable, due to Oracle's requirement for downtime if the schema changes (CopyEvolve drops/recreates tables), and Oracle doesn't support schema collections, so you can't bind an XML column to multiple schemas.
    Here is some sample code of what I'm trying to do:
    create table BulkTest
    ID NUMBER(10) not null primary key,
    USERFIELDS XMLTYPE
    create sequence S_BulkTest;
    --Document conforming to version 1 of schema
    INSERT INTO BulkTest(id, Userfields) VALUES
    (S_BulkTest.Nextval,
    '<?xml version="1.0" encoding="utf-8" ?>
    <mt395 xmlns="urn:incident:mt395-1">
         <reference>FH12345678</reference>
         <relatedReference>FH23456789</relatedReference>
         <queries>Here is some query text.</queries>
         <narrative>Here is some narrative text.</narrative>
         <relatedMessageType>300</relatedMessageType>
         <relatedMessageDate>2005-03-29</relatedMessageDate>
         <direction>R</direction>
         <sessionNumber>1234</sessionNumber>
         <isn>123456</isn>
         <relatedMessageDescription>This is the deal where I bought USD 1 million for GBP at 1.76.</relatedMessageDescription>
         <otherParty>232332</otherParty>
    </mt395>'
    --Document conforming to version 2 of schema
    INSERT INTO BulkTest(id, Userfields) VALUES
    (S_BulkTest.Nextval,
    '<?xml version="1.0" encoding="utf-8" ?>
    <mt395 xmlns="urn:incident:mt395-2">
         <guid>0f9a08f6-b052-4693-baba-8f7dc881e7e8</guid>
         <reference>333333</reference>
         <queries>Another query</queries>
         <narrative>Some narrative</narrative>
         <direction>R</direction>
         <sessionNumber>1234</sessionNumber>
         <isn>223456</isn>
    </mt395>'
    --It seems I need to create a new index for each field I want to search on
    create index iBulkTest_REFERENCE
    on BulkTest
    (extractValue(UserFields,'/mt395/reference', 'xmlns="urn:incident:mt395-1"'));
    --And that a new index is required for each specifc namespace that is present
    --Can't we include a wildcard in the namespace ?
    create index iBulkTest_REFERENCE_2
    on BulkTest
    (extractValue(UserFields,'/mt395/reference', 'xmlns="urn:incident:mt395-2"'));
    --If I want to query, I have to explicitly specify each namespace.
    --Can't I specify a wildcard ?
    --This will make it "fun" querying across namespaces!
    select
    id,
    extractValue(UserFields,'/mt395/reference', 'xmlns="urn:incident:mt395-2"') As Reference,
    t.userfields.getclobval() userfields
    from bulktest t
    WHERE extractValue(UserFields,'/mt395/reference', 'xmlns="urn:incident:mt395-2"') = '333333'

    Andy
    #1. You do not have scehma versioning here. Your model is totally incorrect. You shoud not change the namespace when versioning the XML Schema. You have 2 different and totally disjoint XML Schemas. The correct was to version, as distinct from evolve an XML Schema is to change the Schema Location Hint associated with your XML...
    Eg
    INSERT INTO BulkTest(id, Userfields) VALUES
    (S_BulkTest.Nextval,
    '<?xml version="1.0" encoding="utf-8" ?>
    <mt395 xmlns="urn:incident:mt395" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:incident:mt395 mt395-1.xsd">
    <reference>FH12345678</reference>
    <relatedReference>FH23456789</relatedReference>
    <queries>Here is some query text.</queries>
    <narrative>Here is some narrative text.</narrative>
    <relatedMessageType>300</relatedMessageType>
    <relatedMessageDate>2005-03-29</relatedMessageDate>
    <direction>R</direction>
    <sessionNumber>1234</sessionNumber>
    <isn>123456</isn>
    <relatedMessageDescription>This is the deal where I bought USD 1 million for GBP at 1.76.</relatedMessageDescription>
    <otherParty>232332</otherParty>
    </mt395>'
    --Document conforming to version 2 of schema
    INSERT INTO BulkTest(id, Userfields) VALUES
    (S_BulkTest.Nextval,
    '<?xml version="1.0" encoding="utf-8" ?>
    <mt395 xmlns="urn:incident:mt395 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:incident:mt395 mt395-2.xsd">
    <guid>0f9a08f6-b052-4693-baba-8f7dc881e7e8</guid>
    <reference>333333</reference>
    <queries>Another query</queries>
    <narrative>Some narrative</narrative>
    <direction>R</direction>
    <sessionNumber>1234</sessionNumber>
    <isn>223456</isn>
    </mt395>'
    This is the correct way of versioning an XML Schema. THe namespace stays the same, the SchemaLocationHint in the SchemaLocation tag changes.
    Bear in mind that if you use the technique you are currently using you will make any path expressions you need to write absolutely unmaintaining and the processing of them very inefficient.
    Some questions to consider
    Node 'X' in namespace 'X' is never the same as Node 'X' in namespace 'Y'.
    How would you write an Xpath or XQuery that targetted multiple versions, but not all versions ?
    What happens if you have other documents that are really in a different namespace ? Using wildcards can you differentiate them..
    From the problem you are describing and the terminolgy you are using it looks like you've been an early customer of Yukon. MSFT clearly didn't understand schema versioning in the early beta releases and used the 'change the namespace' schema for modelling schema versioning.
    We do have some technology coming down the pipe which can address the issue, regardless of whether or not it is too late for you to correct the versioning scheme you have selected. However I cannot discuss that in a public forum. If you want to learn about these features and are prepared to enter an NDA with Oracle in order to do so please contact me directly. You can do this a number of ways...
    Guess my email address @oracle.com
    Post your email address here and I'll delete the post as soon as I have it..
    Update your OTN Forum profile to include your email address
    Open a TAR and post the tar number here. You can then softclose the tar as this is simply a method for me to get your contact info.

  • CLOB error?

    When I run the Dbms_Xmlgen below, I get error:
    "ORA-06502: PL/SQL: numeric or value error
    ORA-06512: at line 71"
    where line 71 is "Utl_File.Put_Line(l_Output, RESULT);" which I assume it is something to do with size/CLOB?
    I have googled it and try to make changes, but could not get it to work.
    The SQL statement works by itself.
    Any suggestion?
    Thanks
    DECLARE
      l_Output    Utl_File.File_Type;
      p_Filename  VARCHAR2(50);
      Qryctx      Dbms_Xmlgen.Ctxhandle;
      RESULT      CLOB;
      Output_Date VARCHAR2(16);
    BEGIN
      Output_Date := Substr(SYSDATE, 9, 2) || Substr(SYSDATE, 6, 2) ||
                     Substr(SYSDATE, 3, 2);               
      p_Filename  := 'listings.xml';
      l_Output    := Utl_File.Fopen('testing', p_Filename, 'w');
      Utl_File.Put(l_Output, '<?xml version="1.0" encoding="utf-8" ?> ');
      Qryctx := Dbms_Xmlgen.Newcontext('SELECT DISTINCT Evt.Event_Id Detail_Id,
                    Tools_Pkg.Get_Parent_Programme_Detail_Id(Evt.Event_Id) Container_Id,
                    Ch.Channel_Name,
                    Tools_Pkg.Get_Time_Display_2(Evt.Start_Time, 1, 0) Start_Time,
                    Tools_Pkg.Pad_To_Length(Uktv_Tools_Pkg.Bill_Time_Formatter(Evt.Original_Start_Time,
                                                                                    1),
                                                 8) Billed_Time,
                    Tools_Pkg.Get_Time_Display_2((Evt.Start_Time + Evt.Duration),
                                                 1,
                                                 0) End_Time,
                    To_Char(Evt.On_Date, ''DD/MM/YY'') Date,
                    p.Promo_Name Original_Name,
                    '''' Playlist_Name,
                    0 Program_Id,
                    0 Episode_Id,
                    '''' Listing_Title,
                    Tools_Pkg.Get_Time_Display_2(Evt.Duration, 1, 0) Duration,
                    Pt.Playlist_Name House_Number,
                    Ch.Channel_Id,
                    '''' Application_Id,
                    '''' Videoplusid,
                    Otw.Owt,
                    '''' Subtitled,
                    '''' Signed,
                    '''' Ad,
                    c.Description Event_Type
      FROM Event                     Evt,
           Event_Technical_Data      Etd,
           Promo_Timing              Pt,
           Promo_Type                Ptype,
           Promo                     p,
           Additional_Fields_Channel Afc,
           Channel                   Ch,
           Event_Otw                 Otw,
           Codesc                    c
    WHERE Evt.Event_Technical_Data_Id = Etd.Event_Technical_Data_Id
           AND Etd.Promo_Timing_Id = Pt.Promo_Timing_Id
           AND Pt.Promo_Type_Id = Ptype.Promo_Type_Id
           AND Ptype.Promo_Id = p.Promo_Id
           AND Evt.Channel_Id = Afc.Channel_Id
           AND Evt.On_Date >= ''01/jun/07''
           AND Evt.On_Date <= ''01/jun/07''
           AND Evt.Channel_Id = 3868
           AND Evt.Day_Type_Id = 1307000
           AND Evt.Kind_Code = 1094006 --c_Type_Promo
           AND Ch.Channel_Id = Afc.Channel_Id
           AND Evt.Detail_Id = Otw.Event_Id(+)
           AND p.Promo_Category_Code = c.Code
    ORDER BY Date, Channel_Id, Start_Time');
      -- Set the row header to be TEST
      Dbms_Xmlgen.Setrowtag(Qryctx, 'TEST');
      -- Get the result
      RESULT := Dbms_Xmlgen.Getxml(Qryctx);
      Utl_File.Put_Line(l_Output, RESULT);
      Utl_File.Fclose(l_Output);
      --Close context
      Dbms_Xmlgen.Closecontext(Qryctx);
    END;

    Which is why I said to you in your other thread (Re: Creating XML documents that you would be better to use the DBMS_XMLDOM package to output everything in one go.
    If you insist on using UTL_FILE then you are going to have to chop up your CLOB into pieces and output it bit by bit as there is a 32K limit on each piece you output with UTL_FILE.

  • Call function from data base with clob input parameter.

    Hello,
    In this project I use Jdev 11g.
    I call function from database.
    create or replace function get_fa_list (
    p_fa_id_list in clob
    return sys_refcursor
    is
    vCursor sys_refcursor;
    begin
    put_msg ('begin');
    if p_fa_id_list is null then
    put_msg ('CLOB is null!');
    else
    put_msg ('size CLOB: ' || dbms_lob.getlength (p_fa_id_list));
    end if;
    put_msg ('Save');
    open vCursor for
    select rownum as id, s.*
    from (
    select f.latitude, f.longitude, count (distinct f.res_id) as res_count, count (*) as fa_count, 16711680 as color, res_concat_distinct (f.res_id) as station_list
    from mv_frequency_assignment f, table (SplitClob (p_fa_id_list, ',')) l
    where f.ext_system = 'BI' and
    f.ext_sys_id = l.column_value
    group by f.latitude, f.longitude
    ) s;
    put_msg ('Open and End');
    return vCursor;
    end get_fa_list;
    I use TopLink in ejb.
    i use follow code for call function and get result.
    public List<TmpResPoints> findAllPointsBI(String p_id){
    UnitOfWork uow = getSessionFactory().acquireUnitOfWork();
    uow.beginEarlyTransaction();
    StoredFunctionCall call = new StoredFunctionCall();
    call.setProcedureName("get_fa_list");
    call.useUnnamedCursorOutputAsResultSet();
    ClobDomain c = new ClobDomain(p_id);
    //System.out.println(c.toString());
    call.addNamedArgumentValue("p_fa_id_list", c);
    ReadAllQuery query = new ReadAllQuery();
    query.setReferenceClass(TmpResPoints.class);
    query.setCall(call);
    List<TmpResPoints> result = (List<TmpResPoints>)uow.executeQuery(query);
    uow.commit();
    uow.release();
    return result;
    But size parameter "p_fa_id_list" is 0. (geting from temp table in Data base). this code in function >>
    if p_fa_id_list is null then
    put_msg ('CLOB is null!');
    else
    put_msg ('size CLOB: ' || dbms_lob.getlength (p_fa_id_list));
    end if;)
    How I can call this function from dataBase and get result?
    thx,
    Demka.

    What is the SQL generated?
    The argument should just be the Clob value (a String) not the domain object.
    Also try addNamedArgument, and then pass the named argument to the query.
    James : http://www.eclipselink.org

Maybe you are looking for