ORA-00932 in Native Query

Hello.
I'm using some native queries in my EJB 3.0 project.
When I write a native query like
INSERT INTO SOME_TABLE VALUES (:val0, :val1, :val2) and use the executeUpdate() method of the Query interface after assigning all parameters to values other than null everything works OK.
However, if I let any of the values be null (even though that exactly what I want to put in the database) I get the following exception:
java.sql.SQLException: ORA-00932: inconsistent datatypes: expected NUMBER got BINARY
Is there any way to go arround this? I really must write the nulls to the database.
Thanks in advance,
Hugo Oliveira
[email protected]

Do you mean writing a query like
"INSERT INTO SOME TABLES VALUES :val0, NULL, :val2"
instead of
"INSERT INTO SOME TABLES VALUES :val0, :val1, :val2"
where the val1 parameter would be assigned a null variable, or passing a null directly in setParameter (query.setParameter("val1", null)) instead of a null variable (query.setParameter("val1", nulVar))?
Hugo Oliveira
[email protected]

Similar Messages

  • PL/SQL: ORA-00932: inconsistent datatypes: expected UDT got NUMBER

    Hi all,
    Wondering if you could assist? I'm exploring User Types and having a small problem. I'm getting the above error for a user type I have created which I'm calling in a function. Here's what my code looks like which I'm running the 'scott' schema for testing purposes
    SQL> CREATE OR REPLACE TYPE NBR_COLL AS TABLE OF NUMBER;
    2 /
    Type created.
    SQL> create or replace FUNCTION first_rec_only
    2 (
    3 NUM_ID IN NUMBER
    4 ) RETURN NUMBER IS
    5 v_num NBR_COLL;
    6 BEGIN
    7 select deptno into v_num from dept;
    8 RETURN v_num(v_num.FIRST);
    9 END first_rec_only;
    10 /
    Warning: Function created with compilation errors.
    SQL> show errors
    Errors for FUNCTION FIRST_REC_ONLY:
    LINE/COL ERROR
    7/4 PL/SQL: SQL Statement ignored
    7/11 PL/SQL: ORA-00932: inconsistent datatypes: expected UDT got
    NUMBER
    SQL>
    Any clues to what I'm doing wrong? Cheers.

    The deptno column is a number, you cannot directly select a number into your type, you need to use your type's constructor.
    Something like:
    CREATE OR REPLACE FUNCTION first_rec_only (NUM_ID IN NUMBER) RETURN NUMBER IS
       v_num NBR_COLL;
    BEGIN
       SELECT nbr_coll(deptno) INTO v_num from dept;
       RETURN v_num(v_num.FIRST);
    END first_rec_only;Note that although this will compile, it will throw ORA-01422: exact fetch returns more than requested number of rows when you run it. you need to either use the input parameter as a predicate on your query against dept, use rownum = 1 in the query or use bulk BULK COLLECT INTO, depending on what exactly you want to accomplish.
    John

  • Issue in running GTC having Customized & native query

    Hi Experts,
    We are creating "OIM 9.1 - OIM11g SYNC GTC". When Scheduled task is run, this GTC should be updating the records of OIM11g by taking the data from OIM 9.1 DB.
    We have used the following connection parameters:
    Specify Parameter Values Change
    Database Driver oracle.jdbc.driver.OracleDriver
    Database URL jdbc:oracle:thin:@***************:1521:oimusdb
    Database User ID oimdev
    Database Password ********
    Customized Query (USRIMPORT.USR_EMP_TYPE='Employee' or USRIMPORT.USR_EMP_TYPE='Contractor') and USRIMPORT.USR_STATUS<>'Deleted'
    Use Native Query Yes
    Connection Properties
    Parent Table/View Name USRIMPORT
    Child Table/View Names
    Unique Attribute USR_KEY
    Timestamp Attribute USR_CREATED
    Database Date format
    Batch Size All
    Stop Reconciliation Threshold None
    Stop Threshold Minimum Records None
    Source Date Format yyyy/MM/dd HH:mm:ss z
    Reconcile Deletion of Multivalued Attribute Data No
    Reconciliation Type Incremental
    While running the GTC we are getting following error in logs:
    [XELLERATE.GC.FRAMEWORKRECONCILIATION] [tid: OIMQuartzScheduler_Worker-4] [userId: oiminternal] [ecid: 0000JIbnbxk7u1ADrb4ioY1F10jR000002,0] [APP: oim#11.1.1.3.0] Reconciliation Encountered error: [[
    com.thortech.xl.gc.exception.ProviderException: For non-native customized query, please use & for AND and | for OR.
    at com.thortech.xl.gc.impl.recon.DBReconTransportProvider.getCustomizedQueryCondition(Unknown Source)
    For resolving the above issue, we have tried following combinations: (WHICH ARE NOT WORKING TILL NOW)
    1. Scenario 1:
    query: (USRIMPORT.USR_EMP_TYPE='Employee' | USRIMPORT.USR_EMP_TYPE='Contractor') & (USRIMPORT.USR_STATUS='Disabled' | 'USRIMPORT.USR_STATUS='Active')
    USE NATIVE QUERY = 'NO'
    ERROR: [XELLERATE.GC.FRAMEWORKRECONCILIATION] [tid: OIMQuartzScheduler_Worker-4] [userId: oiminternal] [ecid: 0000JIbnbxk7u1ADrb4ioY1F10jR000002,0] [APP: oim#11.1.1.3.0] Reconciliation Encountered error: [[
    com.thortech.xl.gc.exception.ProviderException: For non-native customized query, please use & for AND and | for OR.
    at com.thortech.xl.gc.impl.recon.DBReconTransportProvider.getCustomizedQueryCondition(Unknown Source)
    2. Scenario 2:
    query- (USRIMPORT.USR_EMP_TYPE='Employee' OR USRIMPORT.USR_EMP_TYPE='Contractor') AND (USRIMPORT.USR_STATUS='Disabled' OR 'USRIMPORT.USR_STATUS='Active')
    USE NATIVE QUERY ='yes'
    ERROR:
    class/Method: DBFacade/getRecord encounter some problems: ORA-00920: invalid relational operator[[
    java.sql.SQLSyntaxErrorException: ORA-00920: invalid relational operator
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:457)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:405)
    3. Scenario 3:
    query- (USRIMPORT.USR_EMP_TYPE='Employee' OR USRIMPORT.USR_EMP_TYPE='Contractor') AND (USRIMPORT.USR_STATUS='Disabled' OR 'USRIMPORT.USR_STATUS='Active')
    USE NATIVE QUERY='NO'
    ERROR:
    ERROR] [] [XELLERATE.GC.FRAMEWORKRECONCILIATION] [tid: OIMQuartzScheduler_Worker-6] [userId: oiminternal] [ecid: 0000JIbnbxk7u1ADrb4ioY1F10jR000002,0] [APP: oim#11.1.1.3.0] Reconciliation Encountered error: [[
    com.thortech.xl.gc.exception.ProviderException: For non-native customized query, please use & for AND and | for OR.
    at com.thortech.xl.gc.impl.recon.DBReconTransportProvider.getCustomizedQueryCondition(Unknown Source)
    at com.thortech.xl.gc.impl.recon.DBReconTransportProvider.getQueryCondition(Unknown Source)
    at com.thortech.xl.gc.impl.recon.DBReconTransportProvider.getFirstPage(Unknown Source)
    Please guide me on the same.

    Hi,
    Thanks for this but i have done as per this document. while running i came to know that there are 2 executable programs in the same name. so i need to remove the one executable program then i run this concurrent program to confirm it. that really we achieved it or not.
    Awaiting for your reply
    Thanks
    M.K.Thamaraiselvan.

  • Binding dynamic variable in XQuery doesn't work: ORA-00932

    I have a table with several columns. One of those columns is a XMLType.
    My goal is to have a query which selects rows from the table of which the XML column matches certain criteria.
    I'm trying following example (JDBC) : http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28369/xdb_xquery.htm#insertedID11
    First, I created my own query, which looks like:
    select * from MyTable t, XMLTABLE( xmlnamespaces (DEFAULT 'http://test), 'for $i in /RootElement where $i/SubElement[contains(Element, "someValue")] return "true"' passing t.xmlColumn)This works as expected. Next, as done in the example, I'm trying to replace the "someValue" with a dynamic variable.
    Query then looks like:
    select * from MyTable t, XMLTABLE( xmlnamespaces (DEFAULT 'http://test), 'for $i in /RootElement where $i/SubElement[contains(Element, $val)] return "true"' passing t.xmlColumn, :1 as "val")This does not seem to work, neither in SQLDeveloper nor in java.
    I always get the :
    java.sql.SQLException: ORA-00932: inconsistent datatypes: expected - got CHAR(SQLDeveloper just gives ORA-00932)
    When I put $val between quotes (so "$val") then I get no error, but then I get no results either.
    I think it will not replace $val in that case but just use it as a literal, so thats not what I want
    I also tried to remove "contains" xpath and use the exact same example as on the oracle page
    select * from MyTable t, XMLTABLE( xmlnamespaces (DEFAULT 'http://test), 'for $i in /RootElement where $i/SubElement/Key = $val return "true"' passing t.xmlColumn, :1 as "val")But this doens't help either.
    I'm clueless about this, so any help would be appreciated
    Edited by: user5893566 on Nov 29, 2008 6:24 AM

    Ok, I tested it using the latest enterprise edition (11g) and there it works as expected.
    However, on 10.2.0.1.0 and 10.2.0.3.0 it gives this error.
    Is this a bug which has been fixed or should I do something special on 10g ?
    I installed all of these as normal without any special settings, created the tables and ran the query...

  • ORA-00932 Error using 11g and the SDO_RELATE function. Works fine in 10g

    Hello,
    If I run this query in Oracle 11g:
    SELECT M.FID, MAX(M.VERSION) AS VERSION
    FROM SW_PB.A_ROADNODEINFORMATION M, SW_PB.ROADNODE N
    WHERE M.REFERENCETOROADNODE = N.FID
    AND M.NODEVERSION = N.VERSION
    AND M.CATALOGUEID <= 477
    AND MDSYS.SDO_RELATE( N.GEOM, MDSYS.SDO_GEOMETRY(2003,81989,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,3),MDSYS.SDO_ORDINATE_ARRAY(120000,0,160000,40000)),'MASK=ANYINTERACT QUERYTYPE=WINDOW') = 'TRUE'
    GROUP BY M.FID;
    I get an error regarding the N.GEOM field. The error is as follows:
    ORA-00932: inconsistent datatypes: expected - got MDSYS.SDO_ELEM_INFO_ARRAY
    The same query runs fine on a 10g database with the same data. I've even truncated the N table and still get the error. I've rebuilt the index but it makes no difference and the metadata is exactly the same for this table as it is for other tables that are involved in a similar query.
    It looks like a bug to me but just wondered if anyone else had come across this?
    Thanks,
    Peter.

    Thanks for the reply. I'm really sorry but I haven't created trace files like this for a very long time and have forgotten the best way to read them. This is the start of the trace file, any help with reformatting it would be greatly appreciated.
    Thanks,
    Peter.
    *** 2009-04-23 17:09:22.902
    ----- Error Stack Dump -----
    *** 2009-04-23 17:09:22.917
    ORA-00932: inconsistent datatypes: expected - got MDSYS.SDO_ELEM_INFO_ARRAY
    ----- Current SQL Statement for this session (sql_id=br02jqdwy2utk) -----
    SELECT M.FID, MAX(M.VERSION) AS VERSION
    FROM SW_PB.A_ROADNODEINFORMATION M, SW_PB.ROADNODE N
    WHERE M.REFERENCETOROADNODE = N.FID
    AND M.NODEVERSION = N.VERSION
    AND M.CATALOGUEID <= 477
    AND MDSYS.SDO_RELATE( N.GEOM, MDSYS.SDO_GEOMETRY(2003,81989,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,3),MDSYS.SDO_ORDINATE_ARRAY(120000,0,160000,40000)),'MASK=ANYINTERACT QUERYTYPE=WINDOW') = 'TRUE'
    GROUP BY M.FID
    ----- Call Stack Trace -----
    calling call entry argument values in hex
    location type point (? means dubious value)
    skdstdst()+114      CALLrel  kgdsdst()+0 FB783A0 2
    ksedst1()+91        CALLrel  skdstdst()+0
    ksedst()+50         CALLrel  ksedst1()+0 0 1
    dbkedDefDump()+298  CALLrel  ksedst()+0 0
    5
    ksedmp()+40         CALLrel  dbkedDefDump()+0 3 0
    _dbkdaKsdActDriver(  CALLreg  00000000             3
    )+841
    _dbgdaExecuteAction  CALLreg  00000000             7B50420 FB79A4C
    ()+63
    dbgdaRunAction()+3  CALLrel  dbgdaExecuteAction 7B50420 4D4C148 20C0002
    02 ()+0 FB79A4C
    dbgdRunActions()+4  CALLrel  dbgdaRunAction()+0 7B50420 A789E54
    4
    dbgdProcessEventAc  CALLrel  dbgdRunActions()+0 7B50420 A789E74
    tions()+446
    __VInfreq__dbgdChkE CALLrel _dbgdProcessEventAc  7B50420 120A3370 A789F64
    ventKgErr()+237 tions()+0
    dbkdChkEventRdbmsE  CALLrel  dbgdChkEventKgErr( 7B50420 A7C06F4 3A4
    rr()+33 )+0
    __PGOSF99__ksfpec() CALLrel _dbkdChkEventRdbmsE  3A4
    +110 rr()+0
    _dbgePostErrorKGE()  CALLreg  00000000             120A3370 3A4
    +1601
    dbkePostKGEkgsf() CALLrel _dbgePostErrorKGE()  120A3370 A772020 3A4
    +49 +0
    _kgeade()+268        CALLreg  00000000             120A3370 A772020 3A4
    kgesev()+54         CALLrel  kgeade()+0
    kgesec2()+18        CALLrel  kgesev()+0 120A3370 A772020 3A4 2
    FB7A200
    qctErr932()+217     CALLrel  kgesec2()+0 120A3370 A772020 3A4 1 1
    FB7A468 1 19 FB7A218
    qctErrConvertDataT  CALLrel  qctErr932()+0 995FBCC0 120A3370 F6 FB7A468
    ype()+82 7B C2E85B4 995FBCC0 120A3370
    FB7A468 0 0 FB7A468 0 204
    qecgby()+240        CALLrel  qctErrConvertDataT 995FBCC0 120A3370 F6 0 0 7B
    ype()+0 C2E85B4
    qecpqbcheck()+75    CALLrel  qecgby()+0
    qecdrv()+161        CALLrel  qecpqbcheck()+0 C2ECD7C 0 0 0
    qecdrv()+74         CALLrel  qecdrv()+0
    kkqcttcalo()+383    CALLrel  qecdrv()+0 C2EFBAC
    kkqctdrvGBP()+1841  CALLrel  kkqcttcalo()+0 C2EFBAC 0 C2EFBAC 166A5D4 0 2
    __VInfreq__kkqgbpTr CALLrel _kkqctdrvGBP()+0     A730DD8
    avChkTran()+193
    _qksqbApplyToQbcLoc  CALLreg  00000000             A730DD8 FB7A9BC
    ()+536
    qksqbApplyToQbc()+  CALLrel  qksqbApplyToQbcLoc
    67 ()+0
    kkqctdrvTD()+1000   CALLrel  qksqbApplyToQbc()+ A730DD8 2EF2DA0 FB7A9BC 0
    0
    kkqgbpdrv()+88      CALLrel  kkqctdrvTD()+0 A754820 995FBDF4 6
    kkqdrv()+1520       CALLrel  kkqgbpdrv()+0 A754820 995FBDF4
    kkqctdrvIT()+698    CALLrel  kkqdrv()+0 A754820 0
    apadrv()+1205       CALLrel  kkqctdrvIT()+0 A754820 995FBDF4
    opitca()+1841       CALLrel  apadrv()+0 995FBDF4
    __PGOSF435__kksFull CALLrel _opitca()+0          A7CC9E4 995FBDF4
    TypeCheck()+15
    _rpiswu2()+560       CALLreg  00000000             FB7B718
    kksLoadChild()+860  CALLrel  rpiswu2()+0 AF495220 5 A77DCBB4 16
    8 94591E54 5 A77DCBE0 0 FB7B670
    615F44 0 FB7B718 0
    kxsGetRuntimeLock(  CALLrel  kksLoadChild()+0 120A3370 AE9130D8 FB7C090
    )+1421
    kksfbc()+8954       CALLrel  kxsGetRuntimeLock( 120A3370 A7CC9E4 FB7C090 3 1
    )+0
    kkspsc0()+1882      CALLrel  kksfbc()+0 A7CC9E4 3 108 FB7D2D8 1BB 0 0
    0
    kksParseCursor()+1  CALLrel  kkspsc0()+0
    43
    opiosq0()+2028      CALLrel  kksParseCursor()+0 FB7C610
    kpooprx()+273       CALLrel  opiosq0()+0 3 E FB7C734 A4
    kpoal8()+729        CALLrel  kpooprx()+0 FB7F214 FB7D2D8 1BA 1 0 A4
    _opiodr()+1224       CALLreg  00000000             5E 1C FB7F210
    _ttcpip()+2733       CALLreg  00000000             5E 1C FB7F210 0
    _opitsk()+1278       CALL???  00000000            
    opiino()+1067       CALLrel  opitsk()+0 0 0
    _opiodr()+1224       CALLreg  00000000             3C 4 FB7FC28
    opidrv()+807        CALLrel  opiodr()+0 3C 4 FB7FC28 0
    sou2o()+45          CALLrel  opidrv()+0 3C 4 FB7FC28
    opimaireal()+130 CALLrel _sou2o()+0           FB7FC1C 3C 4 FB7FC28
    opimai()+92         CALLrel  opimai_real()+0 2 FB7FC54
    OracleThreadStart@  CALLrel  opimai()+0
    4()+764
    77E6482C CALLreg 00000000
    00000000 CALL??? 00000000

  • [8i] Case statement generates ORA-00932: inconsistent datatypes

    Note: I am working with an 8i database (yes, it is quite old), and in this situation, I have to deal with the datatypes (i.e. CHAR), I am given to work with.
    I am attempting to calculate the amount of time product waits between manufacturing steps. As I've discovered though, sometimes I get a negative value when subtracting the date the previous step completes from the date the current step starts. As it is generally impossible to start a later step before an earlier step (imagine trying to screw a cap onto a bottle that doesn't have threads cut yet--it just can't happen), what I've found is that sometimes two steps are started on the same day and finished on the same day (though not necessarily the day they started). This situation CAN happen when one person did both steps and logged on to both steps at the same time, rather than logging on to one, then the other. So, what I need to do in these situations is replace the negative number with a zero (I'll treat the later step as having no wait time).
    Here is some sample data:
    (Note: the real data set is the result of a query, and has around 200K rows and more columns, but this should be representative enough to find a solution that works on my actual application.)
    CREATE TABLE     steps
    (     item_id          CHAR(25)
    ,     ord_nbr          CHAR(10)
    ,     sub_nbr          CHAR(3)
    ,     step_nbr     CHAR(4)
    ,     start_date     DATE
    ,     finish_date     DATE
    INSERT INTO steps
    VALUES ('A','0000000001','001','0010',TO_DATE('01/01/2011','mm/dd/yyyy'),TO_DATE('01/02/2011','mm/dd/yyyy'));
    INSERT INTO steps
    VALUES ('A','0000000001','001','0020',TO_DATE('01/01/2011','mm/dd/yyyy'),TO_DATE('01/02/2011','mm/dd/yyyy'));
    INSERT INTO steps
    VALUES ('A','0000000001','001','0030',TO_DATE('01/05/2011','mm/dd/yyyy'),TO_DATE('01/06/2011','mm/dd/yyyy'));
    INSERT INTO steps
    VALUES ('A','0000000001','002','0010',TO_DATE('01/01/2011','mm/dd/yyyy'),TO_DATE('01/02/2011','mm/dd/yyyy'));
    INSERT INTO steps
    VALUES ('A','0000000001','002','0020',TO_DATE('01/04/2011','mm/dd/yyyy'),TO_DATE('01/04/2011','mm/dd/yyyy'));
    INSERT INTO steps
    VALUES ('A','0000000001','002','0030',TO_DATE('01/06/2011','mm/dd/yyyy'),TO_DATE('01/07/2011','mm/dd/yyyy'));
    INSERT INTO steps
    VALUES ('B','0000000002','001','0005',TO_DATE('01/10/2011','mm/dd/yyyy'),TO_DATE('01/12/2011','mm/dd/yyyy'));
    INSERT INTO steps
    VALUES ('B','0000000002','001','0025',TO_DATE('01/10/2011','mm/dd/yyyy'),TO_DATE('01/12/2011','mm/dd/yyyy'));Here is the query I use that returns negative values sometimes:
    SELECT     item_id
    ,     ord_nbr
    ,     sub_nbr
    ,     step_nbr
    ,     start_date - last_step_finished
    FROM     (
         SELECT     s.*
         ,     LAG (s.finish_date)     OVER     (
                                  PARTITION BY     s.item_id
                                  ,          s.ord_nbr
                                  ,          s.sub_nbr
                                  ORDER BY     s.step_nbr
                                  )     AS last_step_finished
         FROM     steps s
    Returns:
    ITEM_ID                   ORD_NBR    SUB STEP START_DATE-LAST_STEP_FINISHED
    A                         0000000001 001 0010
    A                         0000000001 001 0020                        -1.000
    A                         0000000001 001 0030                         3.000
    A                         0000000001 002 0010
    A                         0000000001 002 0020                         2.000
    A                         0000000001 002 0030                         2.000
    B                         0000000002 001 0005
    B                         0000000002 001 0025                        -2.000These are the results I want to see:
    ITEM_ID                   ORD_NBR    SUB STEP START_DATE-LAST_STEP_FINISHED
    A                         0000000001 001 0010
    A                         0000000001 001 0020                         0.000
    A                         0000000001 001 0030                         3.000
    A                         0000000001 002 0010
    A                         0000000001 002 0020                         2.000
    A                         0000000001 002 0030                         2.000
    B                         0000000002 001 0005
    B                         0000000002 001 0025                         0.000And this is what I tried to do to get those results (comment notes what line generated the error):
    SELECT     item_id
    ,     ord_nbr
    ,     sub_nbr
    ,     step_nbr
    ,     CASE
              WHEN     start_dt - last_step_finished     < 0
              THEN     0
              ELSE     start_dt - last_step_finished  -- THIS LINE GENERATES THE ORA-00932 ERROR
         END                         AS days_in_queue
    FROM     (
         SELECT     s.*
         ,     LAG (s.finish_date)     OVER     ( PARTITION BY  s.item_id
                                    ,          s.ord_nbr
                                    ,          s.sub_nbr
                                    ORDER BY     s.step_nbr
                                  )     AS last_step_finished
         FROM     steps s
         );I know I've had inconsistent datatype errors before with case statements in this particular 8i database, but I can't seem to figure out why I'm getting one this time. I think it has something to do with the NULL values that can occur for last_step_finished. Also, if I change the case statement to:
    ,     CASE
              WHEN     start_dt - last_step_finished     < 0
              THEN     NULL
              ELSE     start_dt - last_step_finished  -- THIS LINE GENERATES THE ORA-00932 ERROR
         END     the query runs just fine. But, I don't want NULL, I want 0. In the next level of this query, I will be taking averages by item_id/step_nbr, and I want the 0's to be included in the average. (NULL values, as far as I can tell, would be excluded. AVG(NULL, 1, 2) =AVG (1,2) = 1.5 NOT AVG(0,1,2) = 1).
    Thanks in advance!

    Thanks, TO_NUMBER did the trick. Since you didn't state in your post where to use TO_NUMBER, here is my final solution, in case anyone in the future looks through this thread to find an answer to their question:
    SELECT     item_id
    ,     ord_nbr
    ,     sub_nbr
    ,     step_nbr
    ,     CASE
              WHEN     start_dt - last_step_finished     < 0
              THEN     0
              ELSE     TO_NUMBER(start_dt - last_step_finished)
         END                         AS days_in_queue
    FROM     (
         SELECT     s.*
         ,     LAG (s.finish_date)     OVER     ( PARTITION BY  s.item_id
                                    ,          s.ord_nbr
                                    ,          s.sub_nbr
                                    ORDER BY     s.step_nbr
                                  )     AS last_step_finished
         FROM     steps s
         );Edited by: user11033437 on Jun 27, 2011 11:17 AM
    I see you edited your post to add TO_NUMBER to it.

  • ORA-00932 Using Structured XML Table

    Hello,
    I'm having a problem in trying to create and use a Structured XML Table.
    I have created very small sample that illustrates my problem:
    I have registered the following schema:
    <schema
    targetNamespace="http://tsldev01.thesoftlife.com:7887/SoftTop/Schemas/Jjm.xsd"
    xmlns:jjm="http://tsldev01.thesoftlife.com:7887/SoftTop/Schemas/Jjm.xsd" xmlns="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified">
    <complexType name="JjmType">
    <choice maxOccurs="unbounded">
    <element name = "Key" type = "string"></element>
    <element name = "Type" type = "string"></element>
    <element name = "AccessID" type = "string"></element>
    </choice>
    </complexType>
    <element name ="Jjm" type="jjm:JjmType"/>
    </schema>'
    Then I created the following table:
    CREATE TABLE JJM_SCHEMA of XMLType
    XMLSCHEMA "http://tsldev01.thesoftlife.com:7887/SoftTop/Schemas/Jjm.xsd"
    ELEMENT "Jjm";
    Then I inserted the following row:
    insert into JJM_SCHEMA values(xmltype('<Jjm
                             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                             xsi:noNamespaceSchemaLocation="http://tsldev01.thesoftlife.com:7887/SoftTop/Schemas/Jjm.xsd">
    <Key>anp</Key>
                   <Type>User</Type>
    <AccessID>TSL2</AccessID>
    </Jjm>'));
    Then I do the following query:
    SELECT
    extract(value(x),
    '/Jjm[Type="User"]') AS jjmXML FROM JJM_SCHEMA x
    WHERE existsNode(value(x),'/Jjm[Type="User"]') = 1;
    I get this error:
    ERROR at line 1:
    ORA-00932: inconsistent datatypes: expected UDT got CHAR
    However, if I remove the Xpath predicate [Type="User"] from the "extract()" function and WHERE clause...
    SELECT
    extract(value(x),
    '/Jjm') AS jjmXML FROM JJM_SCHEMA x
    WHERE existsNode(value(x),'/Jjm') = 1;
    The query works.
    Also, If I change the schema from <choice maxOccurs="unbounded"> to <sequence>... either query works.
    I need the "choice" type element to work with the Xpath predicate. Am I missing something?
    Thanks in advance.
    Jim McDowall

    Jim
    Which version of the database are you using...
    Testing with 9.2.0.4.0 I had to add an xmlns declaration to the instance document before I could insert it into the table
    <Jjm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tsldev01.thesoftlife.com:7887/SoftTop/Schemas/Jjm.xsd" xsi:noNamespaceSchemaLocation="http://tsldev01.thesoftlife.com:7887/SoftTop/Schemas/Jjm.xsd">
         <Key>anp</Key>
         <Type>User</Type>
         <AccessID>TSL2</AccessID>
    </Jjm>
    However once that was done I get the following.
    SQL*Plus: Release 9.2.0.4.0 - Production on Wed Aug 20 15:40:32 2003
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    SQL> spool testcase.log
    SQL> set trimspool on
    SQL> connect &1/&2
    Connected.
    SQL> --
    SQL> set timing on
    SQL> set long 10000
    SQL> set pages 10000
    SQL> set feedback on
    SQL> set lines 132
    SQL> --
    SQL> SELECT extract(value(x),'/Jjm[Type="User"]') AS jjmXML
    2 FROM JJM_SCHEMA x
    3 WHERE existsNode(value(x),'/Jjm[Type="User"]') = 1
    4 /
    JJMXML
    <Jjm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tsldev01.thesoftlife.com:7887/SoftTop/S
    noNamespaceSchemaLocation="http://tsldev01.thesoftlife.com:7887/SoftTop/Schemas/Jjm.xsd">
    <Key>anp</Key>
    <Type>User</Type>
    <AccessID>TSL2</AccessID>
    </Jjm>
    1 row selected.
    Elapsed: 00:00:02.07
    SQL> SELECT extract(value(x),'/Jjm') AS jjmXML
    2 FROM JJM_SCHEMA x
    3 WHERE existsNode(value(x),'/Jjm') = 1;
    JJMXML
    <Jjm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tsldev01.thesoftlife.com:7887/SoftTop/S
    noNamespaceSchemaLocation="http://tsldev01.thesoftlife.com:7887/SoftTop/Schemas/Jjm.xsd">
    <Key>anp</Key>
    <Type>User</Type>
    <AccessID>TSL2</AccessID>
    </Jjm>
    1 row selected.
    Elapsed: 00:00:00.00
    SQL> /
    JJMXML
    <Jjm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tsldev01.thesoftlife.com:7887/SoftTop/S
    noNamespaceSchemaLocation="http://tsldev01.thesoftlife.com:7887/SoftTop/Schemas/Jjm.xsd">
    <Key>anp</Key>
    <Type>User</Type>
    <AccessID>TSL2</AccessID>
    </Jjm>
    1 row selected.
    Elapsed: 00:00:00.00
    SQL> quit

  • Ora-00932 "expected number got -"... error comes and goes

    We have several procedures in a package which get called by an asp.net application. The procedures return a sys_refcursor as an out param, by going OPEN param FOR big complicated query. There are about seven procedures which encapsulate different queries. Sometimes, this package seems to just get into a bad mood.
    The symptom is, every time the application calls one of the procedures, it gets back the error "ORA-00932: inconsistent datatypes: expected NUMBER got -", with the line number being the beginning of the "OPEN param FOR" statement. But then, if I open SQL Developer and fiddle around with the package, the error goes away... like, sometimes if I manually invoke one of the procedures in script form from the SQL Developer window, it returns successfully there, and then for the rest of the day the application works fine. Then on some other day the app starts getting the error again. Recompiling the package also sometimes changes the state between erroring and working.
    I don't see how the error message can be a real error if these changing circumstances allow the procedure to work sometimes but not other times with the same data. I also don't understand what "got -" is supposed to mean. I'm scared about what will happen if we ship something behaving this way. Any clues out there as to what is going on?

    I have identified a possible workaround. There's an inner subquery that goes something like this:
    SELECT fields FROM ( subquery_a UNION ALL subquery_b ) LEFT OUTER JOIN table_c ON (condition)
    This in turn gets outer-joined to another subquery. Anyway, when I rewrite this subquery so there's no inside UNION ALL, the error goes away.
    At least in a simplified case.
    [edit] It looks like I have to avoid outer Union Alls as well.
    [edit] And CONNECT_BY_ROOT.
    [edit] And if I don't join one less-essential table. These three conditions actually each lead to three separate errors, any one of which will stop ODP.Net in its tracks though the query runs fine in sql plus or sqldeveloper. Using CONNECT_BY_ROOT causes the "expected NUMBER got -" error (even though the field I'm using it on is varchar2), the UNION ALL causes the internal error, and the harmful join causes a "end-of-file on communication channel". I can cause each of these independently of the other two, and I need three separate workarounds to get my product running!
    I am starting to conclude that ODP.Net, which I was ordered to use because it's so much better than the Microsoft driver, is a sack o sewage.
    Message was edited by:
    pointy
    Message was edited by:
    pointy

  • ORA-00932 while using nvl with trunc function

    What happens when trunc is executed on null?
    I am executing the following query:
    "select nvl(trunc(null),sysdate) from dual"
    and this throws "ORA-00932: inconsistent datatypes: expected NUMBER got DATE, error at Line:1 Column:23".
    Whereas "select nvl(null,sysdate) from dual" returns sysdate correctly.
    Also "select trunc(null) from dual" returns null only. So when the returned null is passed through nvl why am I getting exception?
    This is happening in ver 9.2.0.5.0 and 10.2.0.2.0
    There is another observation, which is an issue that we have found in our code, and while trying to fix that we saw the earlier observation.
    SELECT * FROM orgs, dual where
    trunc(SYSDATE) between trunc(orgs.effective_start_date) and nvl(trunc(orgs.effective_end_date),trunc(sysdate))
    Here effective start date and effective end date for orgs are null for all records.
    When we run this query on ver 9.2.0.5.0, this runs without any exception. But when we run this query on ver 10.2.0.2.0, we get the same exception, "ORA-00932: inconsistent datatypes: expected NUMBER got DATE, error at Line:2 Column:95".
    The join with dual is fake, in actual scenario we have join with other tables, but since we are able to replicate with dual, removed all other details to keep this simple.
    Now if we remove the join with dual, the query works fine in both the env.
    SELECT * FROM orgs where
    trunc(SYSDATE) between trunc(orgs.effective_start_date) and nvl(trunc(orgs.effective_end_date),trunc(sysdate))

    What happens when trunc is executed on null?
    I am executing the following query:
    "select nvl(trunc(null),sysdate) from dual"
    and this throws "ORA-00932: inconsistent datatypes:
    expected NUMBER got DATE, error at Line:1
    Column:23".
    Whereas "select nvl(null,sysdate) from dual" returns
    sysdate correctly.
    Also "select trunc(null) from dual" returns null
    only. So when the returned null is passed through nvl
    why am I getting exception?
    This is happening in ver 9.2.0.5.0 and 10.2.0.2.0The first parameter to NVL is determining the expected datatype of the returned column, with the trunc function defaulting that to NUMBER because it's parameter is NULL. The second parameter to NVL needs to match that datatype which it doesn't because it is a date.
    SQL> select nvl(trunc(sysdate), sysdate) as mydate from dual;
    MYDATE
    26/05/2006 00:00:00
    SQL> select nvl(trunc(null), sysdate) as mydate from dual;
    select nvl(trunc(null), sysdate) as mydate from dual
    ERROR at line 1:
    ORA-00932: inconsistent datatypes: expected NUMBER got DATE
    SQL> select nvl(trunc(123), sysdate) as mydate from dual;
    select nvl(trunc(123), sysdate) as mydate from dual
    ERROR at line 1:
    ORA-00932: inconsistent datatypes: expected NUMBER got DATE
    SQL>

  • ORA-00932 on 11g + sdo_anyinteract + GROUP BY

    select pco.pointclass_id, count(pco.rid) anzahl
    from pointcloud_output pco ,pointcloud_blk_25833 blk where 1=1
    and blk.blk_id = pco.ptn_id and blk.obj_id = (SELECT pc.pc.pc_id
    FROM pointcloud_25833 pc WHERE prin_id = 1)
    and
    MDSYS.SDO_RELATE
    blk.blk_extent
    mdp_utils.get_polygon(
    '602397.7,5343239.79,
    602389.62,5343264.06,
    602416.09,5343265.53,
    602421.23,5343239.79,
    602397.7,5343239.79'
    ,25833)
    ,'MASK=ANYINTERACT'
    ) = 'TRUE'
    group by pco.pointclass_id
    throws this:
    ORA-00932: inconsistent datatypes: expected - got MDSYS.SDO_ELEM_INFO_ARRAY
    On removing the "GROUP BY", the query works., 11gr1
    using SDO_ANYINTERACT, SDO_FILTER doesnt solve the problem
    Similar problem like in:
    Re: ORA-00932 Error using 11g and the SDO_RELATE function. Works fine in 10g
    I made a new thread since I didnt want to hijack the old one.

    Please let us know the explain plan for your query.

  • Help with error select case statement (ORA-00932: inconsistent datatypes)

    Hi,
    I'm struggling to get my sql query work on Oracle..
    I have a table MyTable with 5 columns ( Column1, Column2, Column3, Column4, Column5 ) all are of type NVARCHAR2.
    I need to check whether Column 3, Column 4 are empty or not in that order..and if they values then I wanna append it to Column2.
    For example
    If a row contains the following values,
    Column 2 = a.b
    Column 3 = 123
    Column 4 = xyz
    then column CA = a.b/123/xyz where column CA = temp column
    If either Column 3 or Column 4 is empty/null, then I don't need to append value for that column..
    For example
    Column 2 = a.b
    Column 3 = either NULL or ''
    Column 4 = xyz
    then CA = a.b/xyz where column CA = temp column
    similarly..
    Column 2 = a.b
    Column 3 = 123
    Column 4 = either NULL or ''
    then CA = a.b/123 where column CA = temp column
    Here is my query..
    select MyTable.Column1 as CA0,
    MyTable.Column2 as CA1,
    MyTable.Column3 as CA2,
    MyTable.Column4 as CA3,
    MyTable.Column5 as CA4,
    MyTable.Column2 + CASE WHEN MyTable.Column3 > '' THEN '/' + MyTable.Column3 ELSE '' END + CASE WHEN MyTable.Column4 > '' THEN '/' + MyTable.Column4 ELSE '' END CA
    from MyTable;
    This query works just fine against SQL Server db, but gainst Oracle I'm getting
    ORA-00932: inconsistent datatypes: expected NUMBER got CHAR
    00932. 00000 - "inconsistent datatypes: expected %s got %s"
    Could you please let me know what I'm doing wrong. I need to get this query working on both SQL Server and Oracle..
    Please let me know your suggestions and thoughts..
    Cheers,

    I need to check whether Column 3, Column 4 are empty or not in that order..and if they values then I wanna append it to Column2. In Oracle, you can do it this way - no need to do all kinds of difficult things:
    select col2||col3||col4
      from tbl

  • Parameters in Native Query?

    How can I add parameters to a native query?
    The following approach does not work.
    String query = "select * from a where type=:type";
    Query q = em.createNativeQuery(query, A.class);
    q.setParameter("type", 7);
    q.getResultList();
    I get the following exception:
    Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2006.8 (Build 060908)): oracle.toplink.essentials.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':type AND contains(GeomFromText('POLYGON((2.47 51.037,4.66 51.037,4.66 51.86,2.4' at line 1Error Code: 1064
    Call:SELECT count(*) AS num FROM shipaction WHERE actiontype_id=:type AND contains(GeomFromText('POLYGON((2.47 51.037,4.66 51.037,4.66 51.86,2.47 51.86,2.47 51.037))'),current_pos)
    Query:ResultSetMappingQuery()
    at oracle.toplink.essentials.exceptions.DatabaseException.sqlException(DatabaseException.java:303)
    at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:551)
    at oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:437)
    at oracle.toplink.essentials.threetier.ServerSession.executeCall(ServerSession.java:465)
    at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:213)
    at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:199)
    at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:270)
    at oracle.toplink.essentials.internal.queryframework.DatasourceCallQueryMechanism.executeSelect(DatasourceCallQueryMechanism.java:252)
    at oracle.toplink.essentials.queryframework.ResultSetMappingQuery.executeDatabaseQuery(ResultSetMappingQuery.java:198)
    at oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:609)
    at oracle.toplink.essentials.queryframework.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:536)
    at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2218)
    at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:937)
    at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:909)
    at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:346)
    at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.getSingleResult(EJBQueryImpl.java:471)
    at com.vesseltracker.session.ShipactionUtilBean.countByPolygonAndActionType(ShipactionUtilBean.java:101)

    Hello,
    I had tried it on OC4J with Oracle:
    If q.setParameter(1, 7) had been written
    I've got:
    06/11/16 13:12:01 java.lang.ArrayIndexOutOfBoundsException: 1 > 0
    06/11/16 13:12:01      at java.util.Vector.insertElementAt(Vector.java:558)
    06/11/16 13:12:01      at java.util.Vector.add(Vector.java:776)
    06/11/16 13:12:01      at oracle.toplink.internal.ejb.cmp3.base.EJBQueryImpl.setParameterInternal(EJBQueryImpl.java:349)
    06/11/16 13:12:01      at oracle.toplink.internal.ejb.cmp3.EJBQueryImpl.setParameter(EJBQueryImpl.java:178)
    06/11/16 13:12:01      at com.desyde.tmsissue.model.ejb.session.IssueHoursSessionBean.getIssueHoursById(IssueHoursSessionBean.java:74)
    06/11/16 13:12:01      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    06/11/16 13:12:01      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    06/11/16 13:12:01      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    06/11/16 13:12:01      at java.lang.reflect.Method.invoke(Method.java:585)
    06/11/16 13:12:01      at com.evermind.server.ejb.interceptor.joinpoint.EJBJoinPointImpl.invoke(EJBJoinPointImpl.java:35)
    06/11/16 13:12:01      at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69)
    06/11/16 13:12:01      at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
    06/11/16 13:12:01      at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69)
    06/11/16 13:12:01      at com.evermind.server.ejb.interceptor.system.TxRequiredInterceptor.invoke(TxRequiredInterceptor.java:55)
    06/11/16 13:12:01      at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69)
    06/11/16 13:12:01      at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
    06/11/16 13:12:01      at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69)
    06/11/16 13:12:01      at com.evermind.server.ejb.StatelessSessionEJBObject.OC4J_invokeMethod(StatelessSessionEJBObject.java:86)
    06/11/16 13:12:01      at IssueHoursBean_StatelessSessionBeanWrapper0.getIssueHoursById(IssueHoursBean_StatelessSessionBeanWrapper0.java:72)
    06/11/16 13:12:01      at view.actions.IssuesAction.list(IssuesAction.java:47)
    06/11/16 13:12:01      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    then I've written q.setParameter(0, 7). it helped me to avoid above exception. but I've got another one:
    01:22:07.474--UnitOfWork(1887)--Thread(Thread[ApplicationServerThread-0,5,RequestThreadGroup])--Exception
    [TOPLINK-4002] (Oracle TopLink - 10g Release 3 (10.1.3.0.0) (Build 060118)): oracle.toplink.exceptions.DatabaseException
    java.sql.SQLException: ORA-01008: not all variables bound
    Error code: 1008
    Call:select * from a where type=?1
    Query:ReadAllQuery(com.desyde.tmsissue.model.ejb.entity.IssueHours)
    I've tried to modify query in such ways:
    select * from a where type=?
    select * from a where type=?0
    Have got the same exception.
    Could somebody help me?
    Thanks.

  • Inconsistent datatypes problem (ORA-00932)

    Hi all,
    Given the following two tables , located in two different schemas :
    CREATE TABLE schema1.national_desc
    (     ENT CHAR(18 CHAR),
         COD_MAJ CHAR(1 CHAR),
         SID_DESC_COD_ADD NUMBER(8,0),
         ID_LANG CHAR(2 CHAR) DEFAULT 'FR',
         SID_COD_ADD NUMBER(8,0),
         ID_TYP_COD_ADD CHAR(1 CHAR),
         COD_ADD CHAR(3 CHAR),
         L_DESC NCLOB,
         DAT_MAJ DATE DEFAULT SYSDATE,
         DAT_MAD DATE,
         LL_DESC NCLOB,
         CONSTRAINT pk_national_desc PRIMARY KEY (SID_DESC_COD_ADD, ID_LANG)
    CREATE TABLE schema2.european_desc
    (     ENT CHAR(18 CHAR),
         COD_MAJ CHAR(1 CHAR),
         SID_DESC_COD_ADD NUMBER(8,0),
         ID_LANG CHAR(2 CHAR),
         SID_COD_ADD NUMBER(8,0),
         ID_TYP_COD_ADD CHAR(1 CHAR),
         COD_ADD CHAR(3 CHAR),
         L_DESC NCLOB,
         CONSTRAINT pk_european_desc PRIMARY KEY (SID_DESC_COD_ADD, ID_LANG)
    )we try this query :
    SELECT
    '1' origine,
    sid_cod_add,
    l_desc desc_cod_add,
    TO_CHAR (dat_mad, 'dd/mm/yyyy') dat_mad,
    TO_CHAR (dat_maj, 'dd/mm/yyyy') dat_maj
    FROM
    N24510
    WHERE
    dat_maj > '01/01/2010'
    AND id_lang='FR'
    UNION
    SELECT
    '0',
    sid_cod_add,
    l_desc,
    NULL,
    NULL
    FROM
    F24510
    where
    id_lang='FR'and Oracle complains with this error : ORA-00932.
    We have tried to "cast" the L_DESC column with TO_CHAR but some column value exceeds 4000 chars.
    Casting with TO_CLOB give the same first error.
    Any idea ?
    Stephan
    Oracle 10Gr2 - 10.2.0.3.0
    Linux 64bits

    Hi ,
    Thanks for your reply. We have finally find the problem :)
    Instead of UNION, we perform an UNION ALL. With UNION Oracle had to check unicity
    between rows containing NCLOB columns...
    Hopefully, in our case UNION ALL does the trick !
    Stephan

  • ORA-00932: inconsistent datatypes: expected - got -

    Hi,
    I have writen PL/SQL packages for data loging through pipe lined function for better peformance.The below packages has been compiled sucessfully but during the run time it shows an error
    like "ORA-00932: inconsistent datatypes: expected - got -".
    CREATE OR REPLACE PACKAGE pkg_mkt_hub_load
    AS
         PROCEDURE sp_final_load_mkt_hub;
           FUNCTION fnc_pipe_tot_lvl_idx_mon_hub
        (pi_input_cur IN SYS_REFCURSOR)
       RETURN tot_lvl_idx_mon_tt
       PIPELINED;
    END pkg_mkt_hub_load;
    CREATE OR REPLACE PACKAGE BODY pkg_mkt_hub_load
    AS
      c_default_limit CONSTANT PLS_INTEGER:=5000;
      c_created_dt    CONSTANT DATE:=SYSDATE;
      c_created_user  CONSTANT VARCHAR2(20):='SYSTEM';
      c_updated_dt    CONSTANT DATE:=SYSDATE;
      c_updated_user  CONSTANT VARCHAR2(20):='SYSTEM';
      -- to get the debug desc for updating process log table
      vg_debug_log_desc mkt_process_log.debug_log_desc%TYPE;
      --to get process log key
      vg_process_log_ky mkt_process_log.process_log_ky%TYPE;
       -- reset the all variables.
      PROCEDURE sp_reset_global_variables;
      PROCEDURE sp_final_lvl_idx_mon_hub;
      --PROCEDURE sp_final_lvl_idx_dly_hub;
      FUNCTION fnc_pipe_tot_lvl_idx_mon_hub
        (pi_input_cur IN SYS_REFCURSOR)
       RETURN tot_lvl_idx_mon_tt
       PIPELINED
      AS
       vl_lvl_idx_mon_cur_data tot_lvl_idx_mon_tt;
       BEGIN
         LOOP
          FETCH pi_input_cur BULK COLLECT INTO vl_lvl_idx_mon_cur_data LIMIT c_default_limit;
          EXIT WHEN vl_lvl_idx_mon_cur_data.COUNT = 0;
          FOR i IN 1 .. vl_lvl_idx_mon_cur_data.COUNT
          LOOP
            PIPE ROW (tot_lvl_idx_mon_ot(vl_lvl_idx_mon_cur_data(i).SSIA_INDEX_ID,
            vl_lvl_idx_mon_cur_data(i).start_date,vl_lvl_idx_mon_cur_data(i).currency,
          vl_lvl_idx_mon_cur_data(i).level1,vl_lvl_idx_mon_cur_data(i).type,
          vl_lvl_idx_mon_cur_data(i).RETURN_MONTH,vl_lvl_idx_mon_cur_data(i).RETURN_3MONTHS,
          vl_lvl_idx_mon_cur_data(i).RETURN_6MONTHS,vl_lvl_idx_mon_cur_data(i).RETURN_YTD,
          vl_lvl_idx_mon_cur_data(i).RETURN_1YEAR,vl_lvl_idx_mon_cur_data(i).RETURN_3YEARS,
          vl_lvl_idx_mon_cur_data(i).RETURN_5YEARS,vl_lvl_idx_mon_cur_data(i).RETURN_10YEARS,
          vl_lvl_idx_mon_cur_data(i).MARKET_CAP));
          END LOOP;
          END LOOP;
          CLOSE pi_input_cur;
          RETURN;
       END fnc_pipe_tot_lvl_idx_mon_hub;     
       PROCEDURE sp_final_lvl_idx_mon_hub
       AS
       BEGIN
       MERGE INTO mkt_total_lvl_indx_mon_hub idxhub  
       USING TABLE(pkg_mkt_hub_load.fnc_pipe_tot_lvl_idx_mon_hub(CURSOR(SELECT idxmap.ssia_index_code,idxstg.start_date,idxstg.currency,idxstg.level1,idxstg.type,
           idxstg.return_month,idxstg.return_3months, idxstg.return_6months, idxstg.return_ytd, idxstg.return_1year,
           idxstg.return_3years, idxstg.return_5years,idxstg.return_10years,idxstg.market_cap
         FROM   mkt_total_lvl_indx_mon_stg idxstg,
                 md_vendor_index_map idxmap
         WHERE  idxmap.source = idxstg.source
                 AND idxmap.base_currency = idxstg.currency
                 AND idxmap.return_type = idxstg.TYPE
                 AND idxmap.mkt_index_id = idxstg.vendor_code
                 AND idxmap.monthly = 'Y'
                 AND idxmap.file_type = 'T'))) idxmonstg
         ON (idxhub.ssia_index_id=idxmonstg.ssia_index_id)
         WHEN MATCHED THEN
         UPDATE set effective_date=idxmonstg.start_date,
                      CURRENCY=idxmonstg.currency,
                      INDEX_LEVEL=idxmonstg.LEVEL1,
                      TYPE=idxmonstg.type,
                      return_month=idxmonstg.return_month,
                      return_3months=idxmonstg.return_3months,
                      return_6months=idxmonstg.return_6months,
                      return_ytd=idxmonstg.return_ytd,
                      return_1year=idxmonstg.return_1year,
                      return_3years=idxmonstg.return_3years,
                      return_5years=idxmonstg.return_5years,
                      return_10years=idxmonstg.return_10years,
                      market_cap=idxmonstg.market_cap,
                      updated_dt=SYSDATE,
                      updated_user='MICHAEL'
         WHEN NOT MATCHED THEN
          INSERT (  ssia_index_id,
                    effective_date,
                      currency,
                      INDEX_LEVEL,
                      TYPE,
                      return_month,
                      return_3months,
                      return_6months,
                      return_ytd,
                      return_1year,
                      return_3years,
                      return_5years,
                      return_10years,
                      market_cap,
                      created_dt,
                      created_user)
         VALUES(        idxmonstg.ssia_index_id,
                      idxmonstg.start_date,
                      idxmonstg.currency,
                      idxmonstg.LEVEL1,
                      idxmonstg.type,
                      idxmonstg.return_month,
                      idxmonstg.return_3months,
                      idxmonstg.return_6months,
                      idxmonstg.return_ytd,
                      idxmonstg.return_1year,
                      idxmonstg.return_3years,
                      idxmonstg.return_5years,
                      idxmonstg.return_10years,
                      idxmonstg.market_cap,
                   SYSDATE,
                   'MICHAEL');     
       END sp_final_lvl_idx_mon_hub;
       PROCEDURE sp_final_load_mkt_hub
       as
       BEGIN
        sp_final_lvl_idx_mon_hub;
       END sp_final_load_mkt_hub;
       PROCEDURE Sp_reset_global_variables
       AS
       BEGIN
       vg_debug_log_desc := NULL;
       END sp_reset_global_variables;      
    END pkg_mkt_hub_load;
    SHOW ERRORS  Error:
    ERROR at line 1:
    ORA-00932: inconsistent datatypes: expected - got -
    ORA-06512: at "GPAIHMKTDTA.PKG_MKT_HUB_LOAD", line 33
    ORA-06512: at "GPAIHMKTDTA.PKG_MKT_HUB_LOAD", line 55
    ORA-06512: at "GPAIHMKTDTA.PKG_MKT_HUB_LOAD", line 92
    ORA-06512: at line 1
    types scripts:
    create or replace type tot_lvl_idx_mon_ot as object
    (SSIA_INDEX_ID  VARCHAR2(60),
    start_date date,
    CURRENCY               VARCHAR2(10),
    LEVEL1                  NUMBER(31,11),
    TYPE                    VARCHAR2(31) ,
    RETURN_MONTH            NUMBER(31,11),
    RETURN_3MONTHS          NUMBER(31,11),
    RETURN_6MONTHS          NUMBER(31,11),
    RETURN_YTD              NUMBER(31,11),
    RETURN_1YEAR            NUMBER(31,11),
    RETURN_3YEARS           NUMBER(31,11),
    RETURN_5YEARS           NUMBER(31,11),
    RETURN_10YEARS          NUMBER(31,11),
    MARKET_CAP              NUMBER(31,11));
    create or replace type tot_lvl_idx_mon_tt is table of tot_lvl_idx_mon_ot;how to resolve this issue?

    >
    could you please pointed out whether ref cursor used method correct or not?
    >
    The use looks correct but without your tables and DDL we can't even try to reproduce the problem.
    Notice how you had to break down the process to find out the query that is causing the problem?
    select *
    from TABLE(pkg_mkt_hub_load.fnc_pipe_tot_lvl_idx_mon_hub(CURSOR(SELECT . . .Unfortunately, this is where you should have started when you began creating the process.
    You are trying to design, implement and debug a process using code that has 3,4, 5 or more layers and objects and tables that have a dozen or more columns.
    That is not the way I would recommend especially if you do not have experience with some of the pieces like object types and tables, pipelined functions and ref cursors. You are trying to deal with too many complications at the same time.
    Here is how I would approach this if I were you.
    1. Get the process to work first and then build on it. Start by copying and hacking up what you already have.
    2. Create a very simple version of each of the pieces
    3. Create an object type like 'tot_lvl_idx_mon_ot' with only one or two columns.
    4. Create an object type like 'tot_lvl_idx_mon_tt' as a table of that simple object type
    5. Create a pipelined function that uses the two new simple types, simply hard-codes a value for one or two rows and then pipes out the rows.
    6. Use a simple query like the last one you posted to query the simple pipelined function
    select *
    from TABLE(pkg_mkt_hub_load.simpe_pipeline_function(CURSOR(SELECT . . .Work on that simple set of objects until you have the process defined and working.
    Then expand the now working example to use get the data values dynamically and to use more complicated objects.
    Start with something simple that works. Then build on it.
    It will take a lot less time and will point out other issues with your approach to this. Also, if you try a simple version using the SCOTT emp or dept table and it doesn't work you can post the code and we can try to reproduce it and help find the problem.

  • Getting ORA-00932 with any object table

    Hi, I'm new to Oracle and it's enormous community so I apologize in advance for posting
    in the wrong place or for giving not enough information.
    As I just said, I'm new to Oracle therefore I'm following the [introductory guide|http://www.mcs.csueastbay.edu/support/oracle/doc/10.2/appdev.102/b14260/adobjint.htm#sthref102] and trying the examples it gives one-by-one.
    I used to use MySql in the past but now I need to use a more stable and scalable database that allows
    the storage of objects.
    I'm using Oracle 10.g XE on a GNU/Linux computer (Ubuntu 8.10)
    Let's start with the question:
    in the Example 1-6 the following code is given:
    CREATE TYPE emp_person_typ AS OBJECT (
      name     VARCHAR2(30),
      manager  REF emp_person_typ );
    Type created.
    CREATE TABLE emp_person_obj_table OF emp_person_typ;
    Table created.
    INSERT INTO emp_person_obj_table
      SELECT emp_person_typ ('Bob Jones', REF(e))
        FROM emp_person_obj_table e
        WHERE e.name = 'John Smith';
    1 row(s) inserted.Executing these queries return successfull messages.
    But when I try to retrieve the records by using this query:
    select * from emp_person_obj_table;or when accessing the "Data" tab of that table in the Object Browser"
    I get this error:
    (error report:)
    ORA-00932: inconsistent datatypes: expected NUMBER got REF RESMAN.EMP_PERSON_TYPAll queries are executed in the Application Express (2.1.0.00.39) query runner.
    I think I did everything in the right manner, although the code is just copy-pasted from the guide, so I can't realize
    why this annoying error is still appearing when accessing that table.
    I noticed that executing the same selection query as above in the SQL*Plus CLI works as expected
    and returns a resultset.
    Thanks in advance for any reply.

    Since the query works in SQL*Plus, I would tend to assume that this is a limitation of the APEX query runner. If you post over in the APEX forum, someone may be able to confirm that or suggest a way of working around it.
    Do you need to use the APEX query runner? Could you use SQL*Plus or SQL Developer instead?
    Justin

Maybe you are looking for