XMLSequence: inconsistent datatypes?

Hello,
I can't get data from XMLsequence into a CLOB using getClobVal().
With the code below I get this error:
The following error has occurred:
ORA-06550: line 7, column 17: [the getClobVal() statement]
PL/SQL: ORA-00932: inconsistent datatypes: expected NUMBER got CLOB
ORA-06550: line 7, column 1:
PL/SQL: SQL Statement ignored
xml_t is defined like this: create or replace type xml_t is VARRAY (2000) of CLOB
OMWB_cv1 is a weak ref cursor (created for my stored procedure by the Oracle Migration Workbench)
I want to use XMLSequence to extract the query as XML snippets, and then I'll aggregate them together in a single CLOB. Any ideas on how to accomplish this without the need to explicitly list out the individual columns would be appreciated, since I need to perform this same operation on 125 stored procedures and would rather write a wrapper than rewrite each one. Thanks.
Richard Sonnenblick
rich@enrich***consulting.com (remove *** for email address)
declare
OMWB_cv1 OMWB_emulation.globalPkg.RCT1;
xml_series xml_t;
begin
sa.getallprojectswithsnapshots(OMWB_cv1);
SELECT value(e).getClobval() INTO xml_series
FROM TABLE(XMLSequence(OMWB_cv1)) e;
end;

I'm not sure that I undestand what you are trying to do.
XMLSequence generates a series of XMLType variables, each containing a well formed XML document from a XMLType that contains an XMLFragment. It is typically used in conjunction with the tabel() operator to create a set of rows from a collection.
eg
select count(*) from purchaseorder p,
table(xmlsequence(extract(value(p),'/PurchaseOrder/LineItem'))) t
Would count the number of LineItem elements in each row in the purchaseorder table.

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

  • PL/SQL: ORA-00932: inconsistent datatypes: expected REF got CHAR

    SQL> desc o.rel_module;
    Name Null? Type
    ID NOT NULL NUMBER(6)
    TYPE NOT NULL CHAR(7)
    BUILDDATE NOT NULL NUMBER(4)
    DESIGNROOT NOT NULL NUMBER(6)
    SQL> desc rel_module
    Name Null? Type
    ID NOT NULL NUMBER(6)
    DESIGNROOT NOT NULL NUMBER(6)
    REL_COMPOSITEPARTS REL_COMPOSITEPART_TAB
    SQL> desc REL_COMPOSITEPART_TAB
    REL_COMPOSITEPART_TAB TABLE OF REL_COMPOSITEPART
    SQL> desc REL_COMPOSITEPART
    Name Null? Type
    TYPE CHAR(7)
    BUILDDATE NUMBER(4)
    SQL> create or replace procedure rel_module_p
    2 as
    3 cursor c is select ID, TYPE, BUILDDATE, DESIGNROOT from o.rel_module;
    4 begin
    5 FOR i in c
    6 LOOP
    7 INSERT into rel_module(id,REL_CompositeParts,DESIGNROOT)
    Values (i.ID,REL_CompositePart_TAB(i.type,i.builddate), i.designroot);
    8 END LOOP;
    9 END;
    10 /
    Warning: Procedure created with compilation errors.
    SQL> show err
    Errors for PROCEDURE REL_MODULE_P:
    LINE/COL ERROR
    7/1 PL/SQL: SQL Statement ignored
    7/93 PL/SQL: ORA-00932: inconsistent datatypes: expected REF got CHAR
    Can you please tell me where needs correction.

    801556 wrote:
    Can you please tell me where needs correction.Just a fix would be:
    create or replace procedure rel_module_p
    as
    cursor c is select ID, TYPE, BUILDDATE, DESIGNROOT from o.rel_module;
    begin
    FOR i in c
    LOOP
    INSERT into rel_module(id,REL_CompositeParts,DESIGNROOT)
    values (i.ID,REL_CompositePart_TAB(REL_COMPOSITEPART(i.type,i.builddate)), i.designroot);
    END LOOP;
    END;
    /However, I'd assume what you want is:
    create or replace procedure rel_module_p
    as
    cursor c is select ID,CAST(COLLECT(REL_COMPOSITEPART(TYPE,BUILDDATE)) AS REL_CompositePart_TAB) REL_COMPOSITEPARTS, DESIGNROOT
    from rel_module
    group by id,DESIGNROOT;
    begin
    FOR i in c
    LOOP
    INSERT into rel_moduleX(id,REL_CompositeParts,DESIGNROOT)
    values (i.ID,i.REL_COMPOSITEPARTS, i.designroot);
    END LOOP;
    END;
    /SY.

  • Inconsistent datatypes error when inserting into a object

    I am trying to insert some test data into the table emp.I have managed to succesfully create the objects and types but when I try to insert into the emp table I get a inconsistent datatypes error however I have checked the datatypes and they all seem fine. Can anyone help me.
    thanks
    CREATE OR REPLACE TYPE Address_T AS object
    (ADDR1                VC2_40,
    ADDR2               VC2_40,
    CITY_TX          VC2_40,
    COUNTY_CD          VC2_40,
    POST_CD          VC2_40);
    CREATE OR REPLACE TYPE PERSON_T AS OBJECT (
    LNAME_TX           NAME_T,
    FNAME_TX           NAME_T,
    BIRTH_DATE          DATE,
    TELEPHONE          VC2_20,
    EMAIL               VC2_40);
    CREATE OR REPLACE TYPE EMP_T AS OBJECT (
    EMP_ID     NUMBER (10),
    PERSON     PERSON_T,
    ADDRESS ADDRESS_T,
    HIRE_DATE DATE)
    CREATE TABLE EMP OF EMP_T
    (EMP_ID NOT NULL PRIMARY KEY);
    INSERT INTO EMP VALUES (1,           
    PERSON_T('PETCH',
    'GAVIN',
    '23-JAN-80',
    '(01964)550700',
    '[email protected]'),
    ADDRESS_T('67 CANADA',
    'WALKINGTON',
    'BEVERLEY',
    'EAST YORKSHIRE',
    'HU17 7RL'),
    '11-FEB-02'
    ERROR at line 1:
    ORA-00932: inconsistent datatypes

    Gavin,
    What is your VC2_40 and NAME_T type definition? Your insert used these as varchar2, which is a built-in type not a user-defined type. If you explicitly define these to be varchar2's, the insert statement works fine.
    Regards,
    Geoff
    I am trying to insert some test data into the table emp.I have managed to succesfully create the objects and types but when I try to insert into the emp table I get a inconsistent datatypes error however I have checked the datatypes and they all seem fine. Can anyone help me.
    thanks
    CREATE OR REPLACE TYPE Address_T AS object
    (ADDR1                VC2_40,
    ADDR2               VC2_40,
    CITY_TX          VC2_40,
    COUNTY_CD          VC2_40,
    POST_CD          VC2_40);
    CREATE OR REPLACE TYPE PERSON_T AS OBJECT (
    LNAME_TX           NAME_T,
    FNAME_TX           NAME_T,
    BIRTH_DATE          DATE,
    TELEPHONE          VC2_20,
    EMAIL               VC2_40);
    CREATE OR REPLACE TYPE EMP_T AS OBJECT (
    EMP_ID     NUMBER (10),
    PERSON     PERSON_T,
    ADDRESS ADDRESS_T,
    HIRE_DATE DATE)
    CREATE TABLE EMP OF EMP_T
    (EMP_ID NOT NULL PRIMARY KEY);
    INSERT INTO EMP VALUES (1,           
    PERSON_T('PETCH',
    'GAVIN',
    '23-JAN-80',
    '(01964)550700',
    '[email protected]'),
    ADDRESS_T('67 CANADA',
    'WALKINGTON',
    'BEVERLEY',
    'EAST YORKSHIRE',
    'HU17 7RL'),
    '11-FEB-02'
    ERROR at line 1:
    ORA-00932: inconsistent datatypes

  • Function issue:  inconsistent datatypes?

    Hi all.
    I'm having an issue with a function that converts coordinates to a spatial data type.
    My database version is:
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE     11.2.0.2.0     Production
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    Here's my package that I'm using
    create or replace package make_geometry
    as
                function get_geometry_from_coords (p_coords in clob  )
              return sdo_geometry;
    end;
    create or replace package body make_geometry
    as
              function get_geometry_from_coords (p_coords in clob)
              return sdo_geometry
              is
                 v_geometry sdo_geometry;
              begin
                 --with t as (select p_coords coords from dual)
              select MDSYS.SDO_GEOMETRY(2003,8307,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1)
                                  ,cast(multiset(
                                      select ordset
                                     from (
                                            select regexp_substr( regexp_replace(
                                                                                replace(p_coords,chr(10))
                                                                                 ,' {1,}',',')
                                                                  ,'[^,]+',1,level)  ordset
                                                  ,rownum rn
                                              from dual
                                                               connect by level <= length(regexp_replace(regexp_replace(
                                                                                                   replace(p_coords,chr(10))
                                                                                                   ,' {1,}',','),'[^,]+')) + 1
                                            where mod(rn,3) <> 0
                        ) as sdo_ordinate_array))
                  into v_geometry
                  from dual;
                  return v_geometry;
              end;
    end;
    /basically, it takes a list of coordinates, in the following format:
    with t as (select '130.88214073599997,-12.377589935499998,0 130.88189276799997,-12.378437734999997,0 130.88164895999998,-12.379271400499997,0 ' coords from dual)replaces the spaces with commas and splits the resultant string by comma, then removes the third coordinate in each set (sets delimited by spaces in above example) and converts the result to sdo_geometry type.
    This logic is not where my problem is occurring
    If I run the query found in the package separately, it works fine:
    SQL> with t as (select '130.88214073599997,-12.377589935499998,0 130.88189276799997,-12.378437734999997,0 130.88164895999998,
    -12.379271400499997,0 ' coords from dual)
      2            select MDSYS.SDO_GEOMETRY(2003,8307,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1)
      3                                ,cast(multiset(
      4                                    select ordset
      5                                   from (
      6                                          select regexp_substr( regexp_replace(
      7                                                                              replace(coords,chr(10))
      8                                                                               ,' {1,}',',')
      9                                                                ,'[^,]+',1,level)  ordset
    10                                                ,rownum rn
    11                                            from t
    12                                                             connect by level <= length(regexp_replace(regexp_replace(
    13                                                                                                 replace(coords,chr(10))
    14                                                                                                 ,' {1,}',','),'[^,]+')) +
    1
    15                                                               )
    16                                          where mod(rn,3) <> 0
    17                      ) as sdo_ordinate_array))
    18                from dual;
    MDSYS.SDO_GEOMETRY(2003,8307,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1),CAST(MULTISET(SELECTORDSETFROM(SELECTREGEXP_SUBSTR(REGE
    XP_REPL
    SDO_GEOMETRY(2003, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARRAY(130.882141, -12.37759, 130.881893, -12.378
    438, 13
    0.881649, -12.379271, NULL))but if I call the function:
    SQL> with t as (select '130.88214073599997,-12.377589935499998,0 130.88189276799997,-12.378
    -12.379271400499997,0 ' coords from dual)
      2  select make_geometry.get_geometry_from_coords(coords)
      3    from t;
    select make_geometry.get_geometry_from_coords(coords)
    ERROR at line 2:
    ORA-00932: inconsistent datatypes: expected NUMBER got CLOB
    ORA-06512: at "HR.MAKE_GEOMETRY", line 13If I change the package to expect varchar2 the above example coordinate list works fine, but obviously that doesn't work when the coordinate list exceeds 4000 characters.
    any thoughts?

    not sure that is the problem:
    SQL> create table foo (mr_clob clob);
    Table created.
    SQL>
    SQL> insert into foo values ('testing'||chr(10)||'testing');
    1 row created.
    SQL>
    SQL> select replace(mr_clob,chr(10),'blah') from foo;
    REPLACE(MR_CLOB,CHR(10),'BLAH')
    testingblahtesting
    1 row selected.

  • Inconsistent datatypes:expected - got - error in handling xml

    hi i am getting the error Error(45,12): PL/SQL: ORA-00932: inconsistent datatypes: expected - got - in this procedure
    i tried a lot and landed in confused state..
    create or replace
    PROCEDURE BT_CPE_XML_READ1 IS
    dest_clob CLOB;
    src_clob BFILE := BFILENAME('DOC_PATH', 'tester.xml');
    dst_offset number := 1 ;
    src_offset number := 1 ;
    lang_ctx number := DBMS_LOB.DEFAULT_LANG_CTX;
    warning number;
    ex number;
    v_cast xmltype;
    v_varchar varchar2(32767);
    BEGIN
    DBMS_LOB.CREATETEMPORARY(dest_clob,true);
    ex := dbms_lob.fileexists(src_clob);
    if ex = 1 then
    INSERT INTO test_clob(id, file_name, XML_FILE_COLUMN, timestamp)
    VALUES(1001, 'test.xml', empty_clob(), sysdate)
    RETURNING XML_FILE_COLUMN INTO dest_clob;
    DBMS_LOB.OPEN(src_clob, DBMS_LOB.LOB_READONLY);
    DBMS_LOB.LoadCLOBFromFile(
    DEST_LOB => dest_clob
    , SRC_BFILE => src_clob
    , AMOUNT => DBMS_LOB.GETLENGTH(src_clob)
    , DEST_OFFSET => dst_offset
    , SRC_OFFSET => src_offset
    , BFILE_CSID => DBMS_LOB.DEFAULT_CSID
    , LANG_CONTEXT => lang_ctx
    , WARNING => warning
    DBMS_OUTPUT.ENABLE(100000);
    DBMS_LOB.CLOSE(src_clob);
    COMMIT;
    DBMS_OUTPUT.PUT_LINE('Loaded XML File using DBMS_LOB.LoadCLOBFromFile: (ID=1001).');
    v_cast :=xmltype(dest_clob);
    --dbms_output.put_line(v_cast);
    select extractvalue(XML_FILE_COLUMN,'/modifyProductPortfolioRequest/ns1:stateCode') from test_clob;
    end if;
    END BT_CPE_XML_READ1;
    is there any other way to get the value(xml)from the clob column of a table

    I see two issues off a quick eye-ball of the code<br><br>
    #1) You insert an empty clob into your table, load a local variable with the XML from disk, and then query the table. You never insert the XML into the table so you are querying on an empty column in the table.<br><br>
    #2) extractValue allows a third parm which is the namespace string. Since your XPath contains ns1: you'll need to use the third parm

  • Inconsistent datatypes: expected - got -

    hi i am getting the error Error(45,12): PL/SQL: ORA-00932: inconsistent datatypes: expected - got - in this procedure
    i tried a lot and landed in confused state..
    create or replace
    PROCEDURE BT_CPE_XML_READ1 IS
    dest_clob CLOB;
    src_clob BFILE := BFILENAME('DOC_PATH', 'tester.xml');
    dst_offset number := 1 ;
    src_offset number := 1 ;
    lang_ctx number := DBMS_LOB.DEFAULT_LANG_CTX;
    warning number;
    ex number;
    v_cast xmltype;
    v_varchar varchar2(32767);
    BEGIN
    DBMS_LOB.CREATETEMPORARY(dest_clob,true);
    ex := dbms_lob.fileexists(src_clob);
    if ex = 1 then
    INSERT INTO test_clob(id, file_name, XML_FILE_COLUMN, timestamp)
    VALUES(1001, 'test.xml', empty_clob(), sysdate)
    RETURNING XML_FILE_COLUMN INTO dest_clob;
    DBMS_LOB.OPEN(src_clob, DBMS_LOB.LOB_READONLY);
    DBMS_LOB.LoadCLOBFromFile(
    DEST_LOB => dest_clob
    , SRC_BFILE => src_clob
    , AMOUNT => DBMS_LOB.GETLENGTH(src_clob)
    , DEST_OFFSET => dst_offset
    , SRC_OFFSET => src_offset
    , BFILE_CSID => DBMS_LOB.DEFAULT_CSID
    , LANG_CONTEXT => lang_ctx
    , WARNING => warning
    DBMS_OUTPUT.ENABLE(100000);
    DBMS_LOB.CLOSE(src_clob);
    COMMIT;
    DBMS_OUTPUT.PUT_LINE('Loaded XML File using DBMS_LOB.LoadCLOBFromFile: (ID=1001).');
    v_cast :=xmltype(dest_clob);
    --dbms_output.put_line(v_cast);
    select extractvalue(XML_FILE_COLUMN,'/modifyProductPortfolioRequest/ns1:stateCode') from test_clob;
    end if;
    END BT_CPE_XML_READ1;
    is there any other way to get the value(xml)from the clob column of a table

    I see two issues off a quick eye-ball of the code<br><br>
    #1) You insert an empty clob into your table, load a local variable with the XML from disk, and then query the table. You never insert the XML into the table so you are querying on an empty column in the table.<br><br>
    #2) extractValue allows a third parm which is the namespace string. Since your XPath contains ns1: you'll need to use the third parm

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

  • [Oracle 8i] ORA-00932 Inconsistent Datatypes

    Hopefully this is a quick question to answer. In running a query I get the 'inconsistent datatypes' error, and I've narrowed the error down to one part of my query:
    SELECT     CASE     
              WHEN     sopn.plan_start_dt < SYSDATE     THEN SYSDATE
              ELSE     sopn.plan_start_dt
         END                                             
    FROM     SOPN sopn(replacing SYSDATE with an actual hard-coded date doesn't work either)
    The field sopn.plan_start_dt is definitely a date datatype. If I do a simple query for just that field with a date parameter in my where statement, it works just fine, for example:
    SELECT     sopn.plan_start_dt
    FROM     SOPN sopn
    WHERE     sopn.plan_start_dt<SYSDATEdoes not give me any errors.
    I'm guessing there's something wrong with my case statement, or maybe case statements with date parameters are something Oracle 8i doesn't get along with...
    If anyone can tell me why my case statement is causing an 'inconsistent datatype' error, I'd appreciate it. Thanks!

    Well, this tells me column sopn.plan_start_dt datatype is not DATE. CASE requires all branches to return same type expressions. Most likely sopn.plan_start_dt is VARCHAR2 and it is very bad coding to rely on implicit comversions. Use TO_DATE with proper format. For example:
    SELECT     CASE     
              WHEN     TO_DATE(sopn.plan_start_dt,'DD-MON-YY') < SYSDATE     THEN SYSDATE
              ELSE     TO_DATE(sopn.plan_start_dt,'DD-MON-YY')
         END                                             
    FROM     SOPN sopnSY.

  • A problem with inconsistent datatypes

    Whenever I try inserting a new record of type t_cliente_societa in my Cliente table, I get ORA-00932 inconsistent datatypes error and I'm not able to find the reason.
    Could anyone help me? Thanks in advance.
    I'll post my SQL code here. please ignore member functions for I havent' included the code necessary to create the needed tables.
    I defined some types useful for storing informations about the entities I have to deal with.
    The main type is t_cliente and its subtypes are t_cliente_pers and t_cliente_soc.
    I use polymorphism to insert records based on subtypes instancies into a table based on supertype.
    When I would add a new t_cliente_pers record, first I add it into Persona table and then into Cliente table.
    The latter contains a REF to Persona for I have several "persons" who aren't "clients" and I use a single table to store them all.
    create or replace TYPE t_indirizzo AS OBJECT (
    via VARCHAR(45),
    numero NUMBER(4),
    cap INTEGER(5),
    citta VARCHAR(30),
    provincia VARCHAR(30),
    regione VARCHAR(30),
    MEMBER FUNCTION indirizzoCompleto RETURN VARCHAR
    create or replace TYPE t_telefono AS OBJECT (
    num_tel NUMBER(15)
    create or replace TYPE t_telefono_array IS VARRAY(3) OF t_telefono
    create or replace TYPE t_anagrafica AS OBJECT (
    nome VARCHAR(45),
    cognome VARCHAR(45),
    sesso CHAR(1),
    cod_fiscale VARCHAR(16),
    data_nascita DATE
    create or replace TYPE t_ragioneSociale AS OBJECT (
    nome_soc VARCHAR(45),
    data_cost DATE,
    part_iva NUMBER(11)
    create or replace TYPE t_persona AS OBJECT (
    dati_anagrafici t_anagrafica,
    indirizzo t_indirizzo,
    email VARCHAR(45),
    telefono t_telefono_array
    create or replace TYPE t_societa AS OBJECT (
    ragione_sociale t_ragioneSociale,
    indirizzo t_indirizzo,
    email VARCHAR(45),
    telefono t_telefono_array,
    persona_rif t_persona
    create or replace TYPE t_cliente AS OBJECT (
    cod_cliente NUMBER(8),
    MEMBER FUNCTION incFatti RETURN NUMBER,
    MEMBER FUNCTION incSubiti RETURN NUMBER,
    MEMBER FUNCTION incFattiPeriodo RETURN NUMBER,
    MEMBER FUNCTION incSubitiPeriodo RETURN NUMBER,
    MEMBER FUNCTION nomeCliente RETURN VARCHAR,
    MEMBER FUNCTION tipoCliente RETURN VARCHAR
    ) NOT FINAL
    CREATE OR REPLACE TYPE BODY t_cliente AS
    MEMBER FUNCTION incFatti RETURN NUMBER
    IS incidenti NUMBER;
    BEGIN
    SELECT count(i. cod_incidente) INTO incidenti
    FROM Incidenti i, Mezzi m
    WHERE SELF.cod_cliente = m.possessore.cod_cliente AND m.num_targa = i.mezzo. num_targa AND i. responsabilita = ‘c’;
    RETURN (incidenti);
    END;
    MEMBER FUNCTION incSubiti RETURN NUMBER
    IS incidenti NUMBER;
    BEGIN
    SELECT count(i. cod_incidente) INTO incidenti
    FROM Incidenti i, Mezzi m
    WHERE SELF.cod_cliente = m.possessore.cod_cliente AND m.num_targa = i.mezzo. num_targa AND i. responsabilita = ‘s’;
    RETURN (incidenti);
    END;
    MEMBER FUNCTION incFattiPeriodo (da DATE, a DATE) RETURN NUMBER
    IS incidenti NUMBER;
    BEGIN
    SELECT count(i. cod_incidente) INTO incidenti
    FROM Incidenti i ,Mezzi m
    WHERE SELF. cod_cliente = m.possessore.cod_cliente AND m. num_targa = i.mezzo. num_targa AND i. responsabilita = ‘c’ AND (i.data BETWEEN da and a);
    RETURN (incidenti);
    END;
    MEMBER FUNCTION incSubitiPeriodo (da DATE, a DATE) RETURN NUMBER
    IS incidenti NUMBER;
    BEGIN
    SELECT count(i. cod_incidente) INTO incidenti
    FROM Incidenti i ,Mezzi m
    WHERE SELF. cod_cliente = m.possessore.cod_cliente AND m. num_targa = i.mezzo. num_targa AND i. responsabilita = ‘s’ AND (i.data BETWEEN da and a);
    RETURN (incidenti);
    END;
    MEMBER FUNCTION nomeCliente RETURN VARCHAR
    IS
    BEGIN
    RETURN TO_CHAR(cod_cliente);
    END;
    MEMBER FUNCTION tipoCliente RETURN VARCHAR
    IS
    BEGIN
    RETURN (‘u’);
    END;
    END ;
    create or replace TYPE t_cliente_pers UNDER t_cliente (
    persona REF t_persona,
    OVERRIDING MEMBER FUNCTION nomeCliente RETURN VARCHAR,
    OVERRIDING MEMBER FUNCTION tipoCliente RETURN VARCHAR
    ) NOT FINAL
    CREATE OR REPLACE TYPE BODY t_cliente_pers AS
    MEMBER FUNCTION nomeCliente RETURN VARCHAR
    IS nc VARCHAR(90) ;
    BEGIN
    SELECT concat(p.dati_anagrafici.nome, concat(' ',p.dati_anagrafici.cognome)) INTO nc
    FROM d;
    RETURN (nc);
    END;
    MEMBER FUNCTION tipoCliente RETURN VARCHAR
    IS
    BEGIN
    RETURN (‘p’);
    END;
    END ;
    create or replace TYPE t_cliente_soc UNDER t_cliente (
    societa t_societa,
    OVERRIDING MEMBER FUNCTION nomeCliente RETURN VARCHAR,
    OVERRIDING MEMBER FUNCTION tipoCliente RETURN VARCHAR
    ) NOT FINAL
    CREATE OR REPLACE TYPE BODY t_cliente_soc AS
    MEMBER FUNCTION nomeCliente RETURN VARCHAR
    IS
    BEGIN
    RETURN (ragione_sociale.nome_soc);
    END;
    MEMBER FUNCTION tipoCliente RETURN VARCHAR
    IS
    BEGIN
    RETURN (‘s’);
    END;
    END ;
    CREATE TABLE persona OF t_persona(
    dati_anagrafici NOT NULL,
    indirizzo NOT NULL,
    email NOT NULL,
    telefono NOT NULL,
    PRIMARY KEY (dati_anagrafici.cod_fiscale)
    CREATE TABLE cliente OF t_cliente(
    PRIMARY KEY (cod_cliente)
    CREATE SEQUENCE seqCliente
    START WITH 1
    INCREMENT BY 1
    MINVALUE 1
    NOMAXVALUE
    NOCYCLE;
    And finally this is the instruction that gives me problems.*
    INSERT INTO cliente VALUES(
    t_cliente_soc(
    seqCliente.NEXTVAL,
    t_societa(
    t_ragioneSociale('Adecco', '01-gen-1999', '12345678901'),
    t_indirizzo('Milano', '18', '21100', 'Varese', 'Varese', 'Lombardia'),
    '[email protected]',
    t_telefono_array(t_telefono('0332563214')),
    t_persona(
    t_anagrafica('Giulia', 'Macchi', 'f', 'MCCGLA80C23L682L', '23-gen-1980'),
    t_indirizzo('Tofane', '2', '23026', 'Arona', 'Novara', 'Piemonte'),
    '[email protected]',
    t_telefono_array(t_telefono('0322123456'), t_telefono('3337894561'))
    /

    I eliminated the entire database and recreated everything. Now it works... Thanks anyway.

  • Inconsistent datatypes error

    Hi,
    I have faced on the following problem in sql statement.
    SQL> SELECT B.NAME, C.FST_NAME, C.LAST_NAME FROM SIEBEL.S_PARTY_PER A, SIEBEL.S_ORG_EXT B, SIEBEL.S_CONTACT C WHERE (B.ROW_ID = A.PARTY_ID AND C.ROW_ID = A.PERSON_ID AND A.PERSON_ID IN (select D.NEW_VAL from SIEBEL.S_AUDIT_ITEM D where D.OPERATION_CD = 'Associate' and (trunc(OPERATION_DT) Between TRUNC (&from) AND TRUNC (&to))));
    Enter value for from: 10/8/2008
    Enter value for to: 10/10/2008
    ERROR at line 1:
    ORA-00932: inconsistent datatypes: expected DATE got NUMBER
    plz help me....

    Your input value is wrong.
    SQL> select * from dual where trunc(sysdate)=&a
      2  /
    Enter value for a: 10/10/2008
    old   1: select * from dual where trunc(sysdate)=&a
    new   1: select * from dual where trunc(sysdate)=10/10/2008
    select * from dual where trunc(sysdate)=10/10/2008
    ERROR at line 1:
    ORA-00932: inconsistent datatypes: expected DATE got NUMBER
    SQL> select * from dual where trunc(sysdate)=&a
      2  /
    Enter value for a: to_date('10/10/2008','dd/mm/yyyy')
    old   1: select * from dual where trunc(sysdate)=&a
    new   1: select * from dual where trunc(sysdate)=to_date('10/10/2008','dd/mm/yyyy')
    D
    X
    SQL>

  • ORA-00932: inconsistent datatypes: expected - got - In 11g, WORKS in 9i!

    Hello,
    Involved in migration of a 9i database to 11g, R2. One of our procedures works in 9i but in 11g gives us "ORA-00932: inconsistent datatypes: expected - got - "
    We tracked down the error in a statement where oracle does a fetch into a sys_refcursor. The fetch happens on a dynamically constructed select statement ( built by varchar concatenation).
    The select statement selects 3 fields, but the fetch into passes 2 variables to the fetch statement. This causes ORA-00932 in 11g R2, but works in 9i.
    Below is a modified procedure we built to demonstrate the problem. if you compile and test, you will see that the procedure runs in 9i but not 11g.
    create or replace procedure testORA00932 is
    v_now date;
    v_fsqltext varchar2(2000);
    v_curs sys_refcursor;
    begin
    v_fsqltext := 'select sysdate, sysdate+1 from dual'; -- select 2 fields
    open v_curs for v_fsqltext;
    loop
    fetch v_curs into v_now; -- fetch 1 field, this statement fails in 11g (ORA-00932), works in 9i
    dbms_output.put_line(v_now);
    exit when v_curs%notfound;
    end loop;
    close v_curs;
    end;
    Is there a compatibility flag we can turn on to resove this problem?
    Edited by: chrisl08 on Mar 29, 2012 11:11 PM

    After researching this a little more, this is a know bug to oracle: Bug 4381035
    According to Oracle, the only available workaround is to provide the same number of define variables as columns in the SELECT statement.

  • 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

  • ORA00932 inconsistent datatypes For member methods in SQLJ Object called from SQLPlus

    Hi, I would very much appreciate advice on the following problem, its a tricky one, here are the full details....
    A) EXECUTIVE SUMMARY....
    I have created an oracle object type by wrapping a SQLData java object with the Oracle Create type statement. I am using Oracle 9i on NT4. However despite following the very few Oracle examples I could find, I get the following error....
    select value(aaa).testint() from dealsobjtab aaa
    ORA-00932: inconsistent datatypes
    select value(aaa).testme() from dealsobjtab aaa
    ORA-00932: inconsistent datatypesHere is what I've done...
    1) Create Java object using SQLData interface (see listing below)
    2) Load the Java source to Oracle 9i
    3) Run the Oracle Create Type statement to wrap the java class
    4) Use the objects in a table and successfully insert rows and query attributes using SQLPlus
    5) Find I can't pull back data from any instance methods without getting an "inconsistant datatypes" error for both string and int datatypes. (see below for queries and output from SQLPlus)
    B) STEP BY STEP DETAILS FOLLOW......
    1) Java Source (in file \dealcalcs\Dealtest.java)
    package dealcalcs;
    import java.sql.SQLException;
    import oracle.jdbc.OracleConnection;
    import oracle.jdbc.OracleTypes;
    import java.sql.*;
    public class Dealtest implements SQLData
    public static final String SQLNAME = "SWITCHBLADE_DATA.DEALTEST";
    public static final int SQLTYPECODE = OracleTypes.STRUCT;
    protected java.math.BigDecimal m_dealid;
    protected java.sql.Timestamp m_startdate;
    protected String m_dealtype;
    protected Double m_facevalue;
    /* constructor */
    public Dealtest() { }
    public void readSQL(SQLInput stream, String type)
    throws SQLException
    setDealid(stream.readBigDecimal());
    setStartdate(stream.readTimestamp());
    setDealtype(stream.readString());
    setFacevalue(new Double(stream.readDouble()));
    if (stream.wasNull()) setFacevalue(null);
    public void writeSQL(SQLOutput stream)
    throws SQLException
    stream.writeBigDecimal(getDealid());
    stream.writeTimestamp(getStartdate());
    stream.writeString(getDealtype());
    if (getFacevalue() == null)
    stream.writeBigDecimal(null);
    else
    stream.writeDouble(getFacevalue().doubleValue());
    public String getSQLTypeName() throws SQLException
    return SQLNAME;
    /* accessor methods */
    public java.math.BigDecimal getDealid() { return m_dealid; }
    public void setDealid(java.math.BigDecimal dealid) { m_dealid = dealid; }
    public java.sql.Timestamp getStartdate() { return m_startdate; }
    public void setStartdate(java.sql.Timestamp startdate) { m_startdate = startdate; }
    public String getDealtype() { return m_dealtype; }
    public void setDealtype(String dealtype) { m_dealtype = dealtype; }
    public Double getFacevalue() { return m_facevalue; }
    public void setFacevalue(Double facevalue) { m_facevalue = facevalue; }
    //These last two are the member methods I call
    public String testme(){
    String tmp = new String("testme worked");
    return tmp;
    public int testint(){
    int tmp = 0;
    tmp = 88;
    return tmp;
    2, 3, 4) Here is how I wrap the uploaded SQLJ object, create a table using it, and put a row in it....
    create or replace type deal_t as object
         external name 'dealcalcs.Dealtest'
    LANGUAGE JAVA USING SQLData (
    DEALID NUMBER (11) external name 'dealid',
    STARTDATE DATE external name 'startdate',
    DEALTYPE VARCHAR2 (50) external name 'dealtype',
    FACEVALUE FLOAT (49) external name 'facevalue',
    MEMBER FUNCTION testme RETURN VARCHAR2
         EXTERNAL NAME 'testme() return java.lang.String',
    MEMBER FUNCTION testint RETURN NUMBER
         EXTERNAL NAME 'testint() return int'
    ) not final
    create table dealsobjtab of deal_t;
    insert into dealsobjtab values ( deal_t(1, to_date('1/jan/1968'), 'NZD/NZD', 500))
    COMMIT
    5) Here I select attributes from the object table, and select using the two member methods, note that my member methods fail miserably, and advice on fixing this would be much appreciated....
    select * from dealsobjtab aaa
    DEALID STARTDATE DEALTYPE FACEVALUE
    1 01/01/1968 NZD/NZD 500
    1 row selected
    select value(aaa).dealid from dealsobjtab aaa
    VALUE(AAA).DEALID
    1
    1 row selected
    select value(aaa).testint() from dealsobjtab aaa
    ORA-00932: inconsistent datatypes
    select value(aaa).testme() from dealsobjtab aaa
    ORA-00932: inconsistent datatypes
    Phew, that was a long email, I hope you are still awake after all that. I have no idea how to solve this, and would really appreciate some advice to get me going.
    Yours Sincerely,
    Michael Cato

    But, i am receiving the error i have mentioned. is it depends on the java version also?
    Please suggest..

  • Error 'Inconsistent datatypes' with Java classes

    Hi,
    I have some Java classes loaded in Oracle 8.1.6, mapped as Object Types, so when I create one object from PL/SQL, JVM ought to create the matching Java object, communicating via the SQLData interface.
    Unfortunately, after the code:
    pippo:=OraMailer('mail.server.com','mymail');
    that creates the PL/SQL object, any code that use member procedures or function wrapping instance methods of the Java class fails with the error 932: Inconsistent datatypes.
    I looked for a mistake in my PL/SQL and Java code, but no error was found.
    It is very important: help me!!!
    Thx

    So here is what you are doing:
    ArrayList results = //get employees from database
    ListIterator langIt = results.listIterator();
    while (langIt.hasNext()) {
      Employee emp = langIt.next();
      String name2 = emp.getName();
      String SSNo = emp.getSSNum();
      results.add(name2);
      results.add(SSNo);
    }So you get a list or Employee objects, then you get an iterator over the list. For each Employee in the list you add the name and SSNo as Strings back to the same list. From the API for ConcurrentModificationException the exception can be thrown when you modify a collection while iterating over the collection - which is precisely what you are doing.
    The ListIterator interface allows you to modify the list through its own methods. Try using:
      langIt.add(name2);
      langIt.add(SSNo);instead.
    Why are you taking the name and SSNo out of the Employee object and placing them back in the same List anyway? That makes no sense to me.

Maybe you are looking for

  • How to get a list of current users and their transactions code?

    SM04 and AL08 give the list, but its not comprehensive.  in sm04, we have to click the username and select sessions and then a new popup comes giving all transactions for the user.  I want a list such that each and every transaction corresponding to

  • Adobe pdf signing with Topaz

    Hi All,      we are facing an issue while signing a pdf. i have a pdf attachment in my gmail and when i download it, i'm asked whether to Open/Save it. I choose Open and the pdf opens up. When i try to sign it, i get an error which says: "The Documen

  • Bookmarks in Safari: do they ALL have to be synced?

    I currently use Firefox as my primary browser and use (Obviously) Safari to sync bookmarks on my iPhone. I'd sort of like to start using Safari as my primary browser (having problems with FF), but I don't want ALL of my gazillion bookmarks syncing on

  • Removing grey-and-white grid background?

    Hey , I installed Acrobat 9 Pro, version 9.4.1, one week ago. Since then, in every opened pdf-document appers an grey-and-white-grid-background (see figure below).  Normally, I would expect a white background, which I get under this setting only, if

  • I've interview tomorrow , still do not know how to run report from forms

    hi all , i asked before about running report from forms 10g rel2 , but vainly , because i could not configure the reports server , and no one told me . now i've an interview tomorrow , and sure it will be included in the task which i have to do . i a