Expression-matter ORA-00932: inconsistent data types

I'm trying to use the following condition

Select

case

When

Count (exception.exception_number) > 1

then 0

on the other

ENTITY_TYPE_DEF.NAME

end name

With the exception of the table, exception_number has a varchar2 data type. My requirement is such that if the number of exception number is greater than 1, it should show 0 (integer) and if not then see the name column of the entity_type_def table (varchar2).

My query fails with the following error

ERROR on line 7:

ORA-00932: inconsistent data types: expected NUMBER obtained TANK

Please could someone suggest a workaround solution for above question.

Hello.

For example,.

Select

case

When

Count (exception.exception_number) > 1

then "0"

on the other

ENTITY_TYPE_DEF.NAME

end name

Tags: Database

Similar Questions

  • ORA-00932: inconsistent data types: expected DATE receipt NUMBER to call OIC OCIStmtExecute OBIEE 11g

    Hi friends,

    I get this error: ORA-00932: inconsistent data types: expected DATE got the NUMBER to the call of the OIC OCIStmtExecute when I'm putting the filter on the date column condition.

    "Sun Time". " Day' < = cast (MAX ("Sun time" "." ")) Date day")) and"Sun Time ". "' Day ' > = TIMESTAMPADD (SQL_TSI_MONTH,-1, cast (MAX ("Sun time".) "Day") as date). "

    I sank the date max, but if I get the above error. I think max (date) creates the problem.

    Please suggest your opinion on that.

    Thank you.

    Thank you for your suggestions.

    I used the variable, and it helped.

    "Sun Time". " Date' <= valueof(maxdate)="" and="" "dim-time"."date"="">= TIMESTAMPADD (SQL_TSI_MONTH-1, VALUEOF (Maxdate))

  • ADF: ORA-00932: inconsistent data types: expected - got TANK

    I get this error while casting. ORA-00932: inconsistent data types: expected - got TANK
    I had departments such as front number... .but must be able to take over the alpha characters... so I changed my Bind Variables in my model: Array string (decimal Big)

    This is the error:

    where dept in (SELECT * FROM TABLE (CAST (: depts AS glc.))) NUMTABTYPE)))

    How can I solve this?... probably need to delete interpreters from here... .but how I it... any help is appreciated.

    I also Type:
    create or replace TYPE NUMTABTYPE in the TABLE to the number; (also I tried to change this option for create or replace TYPE NUMTABTYPE in the TABLE to the varchar2 (200);)

    I changed the table to a string and

    [oracle.jbo.domain.Number]"with java.lang.String to support also supports departments alpha characters... dept can be AB123 (string) or 3344 (number only)

    The entire query
    ============
    SELECT * FROM (SELECT
    NVL ("DEPT", "Grand Total") as DEPT,
    PERIOD_YEAR,
    In summary (round ("Jan real CDA")) 'real Jan CDA. "
    In summary (round ("Feb real CDA")) 'Feb CDA real. "
    In summary (round ("Mar real CDA")) 'Mar CDA real. "
    In summary (round ("Apr CDA")) real 'Real CDA Apr',
    In summary (round ("peut CDA")) real "can actual CDA."
    In summary (round ("Jun real CDA")) 'Jun CDA real. "
    sum (round ("Jul real CDA")) 'Real CDA Jul',
    In summary (round ('Aug real CDA")) 'Aug CDA real."
    In summary (round ("Ms real CDA")) 'Ms CDA real. "
    In summary (round ("Oct real CDA")) 'Oct CDA real. "
    In summary (round ("Nov real CDA")) 'real CDA Nov. "
    In summary (round ('Dec real CDA")) 'Dec CDA real."
    In summary (round ("Jan CDA Budget")) 'Budget of CDA Jan. "
    In summary (round ("Feb CDA Budget")) 'Feb CDA Budget. "
    In summary (round ("Mar CDA Budget")) 'Mar CDA Budget. "
    In summary (round ("Apr CDA Budget")) 'Apr CDA Budget. "
    In summary (round ("can CDA Budget")) 'Budget of CDA can. "
    In summary (round ("Jun CDA Budget")) 'Jun CDA Budget. "
    In summary (round ("Jul CDA Budget")) 'Jul CDA Budget. "
    In summary (round ("Aug CDA Budget")) 'Aug CDA Budget. "
    In summary (round ("Sep CDA Budget")) 'Ms CDA Budget. "
    In summary (round ("Oct CDA Budget")) 'Oct CDA Budget. "
    In summary (round ("Nov CDA Budget")) 'Nov CDA Budget. "
    In summary (round ("CDA Budget Dec")) 'Dec CDA Budget. "
    In summary (round ('Total Budget uncorrected')) "Annual_Budget."
    In summary (round ("Total Budget")) "Revised_BUDGET."
    sum (round ("real CDA")) "YTD_ACTUALS."
    In summary (round ("Jan Actual")) "Jan_ACTUAL."
    In summary (round ('Jan Budget')) "Jan_BUDGET."
    In summary (round ("Jan Actual")) "JanYTDACTUAL."
    In summary (round ('Jan Budget')) "JanYTDBUDGET."
    sum (round ("real Feb")) "Feb_ACTUAL."
    In summary (round ('Feb Budget')) "Feb_BUDGET."
    sum (round ("real Mar")) "Mar_ACTUAL."
    In summary (round ("Budget de Mar")) "Mar_BUDGET."
    sum (round ("real Apr")) "Apr_ACTUAL."
    In summary (round ("Apr Budget")) "Apr_BUDGET."
    In summary (round ("can real")) "May_ACTUAL."
    In summary (round ("Budget can")) "May_BUDGET."
    sum (round ("real Jun")) "Jun_ACTUAL."
    In summary (round ('Jun Budget')) "Jun_BUDGET."
    sum (round ("real Jul")) "Jul_ACTUAL."
    In summary (round ('Jul Budget')) "Jul_BUDGET."
    sum (round ("real Aug")) "Aug_ACTUAL."
    In summary (round ('Aug Budget')) "Aug_BUDGET."
    sum (round ("real Sep")) "Sep_ACTUAL."
    In summary (round ('Ms Budget')) "Sep_BUDGET."
    sum (round ("real Oct")) "Oct_ACTUAL."
    In summary (round ('Oct Budget')) "Oct_BUDGET."
    sum (round ("real Nov")) "Nov_ACTUAL."
    In summary (round ('Nov Budget')) "Nov_BUDGET."
    sum (round ("real Dec")) "Dec_ACTUAL."
    In summary (round ("Dec Budget")) "Dec_BUDGET."
    sum (round ("Jan Budget" + "Jan Budget Adj")) "Jan_Budget_Orig."
    sum (round ("Budget Feb" + "Feb Budget Adj")) "Feb_Budget_Orig."
    sum (round ("Mar Budget" + "Mar Budget Adj")) "Mar_Budget_Orig."
    sum (round ("Apr Budget" + "After Budget Adj")) "Apr_Budget_Orig."
    sum (round ("Budget can" + "Can Budget Adj")) "May_Budget_Orig."
    sum (round ("Jun Budget" + "Jun Budget Adj")) "Jun_Budget_Orig."
    sum (round ("Jul Budget" + "Jul Budget Adj")) "Jul_Budget_Orig."
    sum (round ("Aug Budget" + "August Budget Adj")) "Aug_Budget_Orig."
    sum (round ("Ms Budget" + "Ms Budget Adj")) "Sep_Budget_Orig."
    sum (round ("Oct Budget" + "Oct Budget Adj")) "Oct_Budget_Orig."
    sum (round ("Budget Nov" + "Nov Budget Adj")) "Nov_Budget_Orig."
    sum (round ('Dec Budget '' + '' Dec Budget Adj")) 'Dec_Budget_Orig '.
    GLC. GLC_BUDANAL_ACT_BUD_ADJ_VAR_V mainanal
    where dept in (SELECT * FROM TABLE (CAST (: depts AS glc.))) NUMTABTYPE))) and period_year =: year and substr ("OBJECT", 1, 3). =: excludeObject
    and mainanal. FERC not like 4% '
    Group by the Department, period_year) QRSLT ORDER BY DEPT

    As you say your table does not number but the strings. If you must change the table in an array of strings.

    Timo

  • -Error ORA-00932: inconsistent data types: expected TANK got the NUMBER

    Here is my report query...
    select 
    *
    from   DW_RFA_JOBDATA
    where  FINISH_TIME >= :P1_START_DATE 
    and FINISH_TIME < :P1_END_DATE
         AND RFA_FLAG = (CASE :P1_JOB_CLASSIFICATION WHEN '0' THEN 'LSF'
                                      WHEN '1' THEN 'NON-LSF' 
                                      ELSE RFA_FLAG END)
    The column data type RFA_FLAG is NUMBER(*,0)... I'm view RSA and RSA - not the area of selection, but I get the error ORA-00932: inconsistent data types: expected TANK got the NUMBER >

    I have created a static LOV with LST display 0 return
    Display NON - RSA 1 return...

    Could any body please help me in truble shooting error? How to to convert the data type to number, I have no privileges to make changes to the table...

    Mark you my previous answer as correct? (MOST POINTS!  :))

  • ORA-00932: inconsistent data types: expected - got CURSER

    Hi all

    I created a function and tried to run SQL Plus, but I get an error

    ORA-00932: inconsistent data types: expected - got CURSER

    I tried to debug for centuries, but are unable to the root of what could be the problem. I'd appreciate any help or idea people could offer

    The only consolation I take from this is that Oracle have typo in one of their error messages :)



    SQL MORE CODE
    select * FROM TABLE(CAST(tsoraimpdb.QueryAuthorsFunc(116, 1, -1, 1, 0) as tsoraimpdb.ENTITYIDTABLE));
    THE FUNCTION CODE
    CREATE OR REPLACE FUNCTION &HKImpDB_Schema_Name..QueryAuthorsFunc 
    (
    aKGID NUMBER,
      aPageNumber NUMBER,              -- The page interested
      aPageSize NUMBER,                -- Number of records per page
      aOffset NUMBER,                  -- The offset = number of records already got
      aTotalRecord NUMBER          -- Total number of users in the database
    )
    RETURN sys_refcursor
    as
    l_FuncCur sys_refcursor;
    l_TotalRecord NUMBER(10) := aTotalRecord;
    l_Offset NUMBER(10) := aOffset;
    l_PagingTable TEMP_T_TABLE:= TEMP_T_TABLE();
    
    -- paging set up
    l_MinRecordsOnAPge NUMBER(10); --last record on the previous page
    l_MaxRecordsOnAPge NUMBER(10); --last record on the current page
    begin
    DBMS_OUTPUT.PUT_LINE('start');
    select KnowdePos(rownum,p.ID) bulk collect into l_PagingTable
      FROM KnowledgeGene kg
      INNER JOIN HKResource r ON kg.KGOwner = r.ID
      INNER JOIN Person p ON r.PersonID = p.ID
    WHERE kg.kgid = akgid
    ORDER BY p.FirstName + ' ' + p.LastName;
    
    l_TotalRecord := l_PagingTable.count; -- get total records
    DBMS_OUTPUT.PUT_LINE(  l_TotalRecord);
    
    if aPageSize > 0 then
      if aPageNumber <= 0 then
              Raise_application_error(-20003,'Invalid Page Number');
      else
          l_MinRecordsOnAPge := (aPageNumber-1)*aPageSize;
          l_MaxRecordsOnAPge := aPageNumber*aPageSize;
      end if;
    else -- if @PageSize < 0 return all records
        l_Offset := 0;
        l_MinRecordsOnAPge := 0;
        l_MaxRecordsOnAPge := l_TotalRecord;
    END if;
    
    -- return results for the correct page
    open l_FuncCur for
    SELECT pos
      from HKResource r
      INNER JOIN Person p ON r.PersonID = p.ID
      inner join TABLE(CAST(l_PagingTable AS TEMP_T_TABLE)) on pos = p.id
      WHERE KnowdeID > l_MinRecordsOnAPge - l_Offset AND KnowdeID <= l_MaxRecordsOnAPge - l_Offset;
    
    return l_FuncCur;
    EXCEPTION when NO_DATA_FOUND then null;
    end;

    You cannot get the ref cursor in a table like this. Either use a PL/SQL program to extract the lines of ref cursor and display them via dbms_output.put_line (or something) or load the results into a collection and then cast the collection in a table in your select statement.

  • Why I get this error? ORA-00932: inconsistent data types

    It's my stored procedure, I created to select only the exact amount of records per page to a GridView (for ASP.NET):
    CREATE OR REPLACE
    PROCEDURE SELECT_COMMAND
    (pTable IN VARCHAR2
    , pFields IN VARCHAR2
    , pSortField IN VARCHAR2
    , pPageIndex IN NUMBER
    , pTotalRecs IN NUMBER
    , pResultSet OUT SYS_REFCURSOR
    ) AS
    BEGIN  
      EXECUTE IMMEDIATE 
      'SELECT ' || pFields || ' FROM '
      || '(SELECT '|| pFields ||', ROW_NUMBER() OVER(ORDER BY '|| pSortField ||') ROW_NUM '
      || 'FROM '|| pTable ||') WHERE ROW_NUM BETWEEN '|| to_char(pPageIndex*pTotalRecs) ||' AND '
      || to_char((pPageIndex+1)*pTotalRecs)    
      INTO pResultSet;
      -- Plus 1 to our index because GridView is a zeroth index collection
    END SELECT_COMMAND;
    I then do a test case with the following parameters:
    declare
    p_test sys_refcursor;
    begin
    select_command('v_sig_devices', '"JOB", "LINE"', '"DEVICE_ID"', 0, 10, p_test);
    end;
    But I get the following error:

    >
    Error report: ORA-00932: inconsistent data types: expected - was -.
    ORA-06512: at the 'SIM '. SELECT_COMMAND', line 10
    ORA-06512: at line 4 level
    00932 00000 - ' incompatible data types: wait %s %s got. "
    >

    At first Oracle gave me an error because the figures were not a string. Can I convert it to a string (with to_char) and Oracle is still not satisfied! Any ideas as to why this is happening?

    Thanks for any help you can provide.

    Suppose you want sth. as

    ...
    OPEN pResultSet FOR 'SELECT ' || pFields || ' FROM '
      || '(SELECT '|| pFields ||', ROW_NUMBER() OVER(ORDER BY '|| pSortField ||') ROW_NUM '
      || 'FROM '|| pTable ||') WHERE ROW_NUM BETWEEN '|| to_char(pPageIndex*pTotalRecs) ||' AND '
      || to_char((pPageIndex+1)*pTotalRecs)  ;
    ...
    
  • Error ORA-00932: inconsistent data types

    Hello world

    I'm having a small problem with the error ORA-00932: inconsistent data types. The code below is what I'm working on. The error is on line 12:
    "vStmt: = ' select DDH_HOST_NM, DDH_SCHEMA_NR from ' | '. vSchema |'. < table > @ < DB_LINK > '; ». This is because DDH_HOST_NM is a VARCHAR2 and DDH_SCHEMA_NR a number.

    I know what is the error and where it is but I can't work on how to solve this problem. I tried to use to_char on DDH_SCHEMA_NR but that does not.

    Anyone have an idea how I can fix this problem?

    Thank you
    N.S.N.O.

    DECLARE
    vSchema varchar2 (1000);
    vStmt varchar2 (1000);
    Version number (38);
    CURSOR c_schemas IS
    Select "< SCHEMA-NAME >" as "< scheme name >" twice;
    BEGIN
    Open c_schemas;
    LOOP
    SEEK c_schemas INTO vSchema;
    EXIT WHEN c_schemas % NOTFOUND;
    vStmt: = ' select DDH_HOST_NM, DDH_SCHEMA_NR from ' | vSchema |'. < table > @ < DB_LINK > ';
    Run immediately vStmt in version;
    dbms_output.put_line(vSchema||) e '|| Version);
    END LOOP;
    CLOSE C_schemas;
    END;

    The problem is that you choose 2 columns in a single variable?

    vStmt: = ' select DDH_HOST_NM, DDH_SCHEMA_NR from ' | vSchema |'.

    @';
    Run immediately vStmt in version ;

    This must be either

    vStmt: = ' select DDH_SCHEMA_NR from ' | vSchema |'.

    @';
    Run immediately vStmt in version;

    or

    vStmt: = ' select DDH_HOST_NM, DDH_SCHEMA_NR from ' | vSchema |'.

    @';
    Run immediately vStmt in vHostNm, version;

    where vHostNm should set as a variable too.

  • ORA-00932: inconsistent data types

    Hello
    on 10 GB R2 I have:
    SQL> select x.*
      2  --,      d.descr
      3  from   (
      4         select prcstype, prcsname
      5         ,      dur
      6         ,      avg_dur
      7         ,      freq
      8         ,      rank() over (order by dur desc) prcrnk
      9         from   (
     10                select prcstype, prcsname
     11                ,      count(*) freq
     12                ,      sum(enddttm-begindttm)*86400 dur
     13                ,      avg(enddttm-begindttm)*86400 avg_dur
     14                from   psprcsrqst p
     15                where  begindttm IS NOT NULL
     16                and    enddttm IS NOT NULL /*have completed*/
     17                and    runstatus IN(9,11,14) /*sucessful processes*/
     18                and    begindttm > SYSDATE - 30 /*in the last 30 days*/
     19                group by prcstype, prcsname
     20                )
     21         ) x
     22  ,      ps_prcsdefn d
     23  where  x.prcrnk <= 5
     24  and    d.prcstype(+) = x.prcstype
     25  and    d.prcsname(+) = x.prcsname
     26  order by x.prcrnk;
                  ,      sum(enddttm-begindttm)*86400 dur
                                    *
    ERROR at line 12:
    ORA-00932: inconsistent datatypes: expected NUMBER got INTERVAL DAY TO SECOND
    Question: How can I format sum (enddttm-begindttm) * 86400 hard?

    Thank you.

    Hello

    Sorry, but what are the data types of
    enddttm
    and
    begindttm?

    with q as(select to_date('01-jan-2001') d1,to_date('31-dec-2000') d2  from dual)
    select dump(d1-d2),dump(to_dsinterval('+001 04:45:17'))  from q
    
    DUMP(D1-D2)     DUMP(TO_DSINTERVAL('+00104:45:17'))
    Typ=14 Len=8: 0,0,0,1,0,0,0,0     Typ=190 Len=24: 0,0,0,1,0,0,0,4,0,0,0,45,0,0,0,17,0,0,0,0,10,0,0,0
    

    (a difference between 2 dates gives an interval of time, but wha'ts typ = 14?)

    Published by: user11268895 on August 27, 2010 12:23

  • ORA-00932: inconsistent data types: expected BLOB, CLOB had TANK

    Hello
    When exporting with the EXP utility, I have the following error:
    . exporting private type synonyms
    . exporting object type definitions
    . exporting system procedural objects and actions
    . exporting pre-schema procedural objects and actions
    . exporting cluster definitions
    EXP-00056: ORACLE error 932 encountered
    ORA-00932: inconsistent datatypes: expected BLOB, CLOB got CHAR
    My question is:
    what is the schema? Can there invalid objects by preventing him from EXP (see the Note 339938.1 on metalink).

    Thank you.

    A way perhaps to query dba_feature_usage_statistics that shows in use and query dba_registry features which also shows the features installed.

    HTH - Mark D Powell.

  • ORA-00932: inconsistent data types should had LONG

    Hello

    I would like to convert LONG LOB. I get the following error.
    SQL> desc all_views
     Name                                      Null?    Typ
     ----------------------------------------- -------- ----------------------------
     OWNER                                     NOT NULL VARCHAR2(30)
     VIEW_NAME                                 NOT NULL VARCHAR2(30)
     TEXT_LENGTH                                        NUMBER
     TEXT                                               LONG
     TYPE_TEXT_LENGTH                                   NUMBER
     TYPE_TEXT                                          VARCHAR2(4000)
     OID_TEXT_LENGTH                                    NUMBER
     OID_TEXT                                           VARCHAR2(4000)
     VIEW_TYPE_OWNER                                    VARCHAR2(30)
     VIEW_TYPE                                          VARCHAR2(30)
     SUPERVIEW_NAME                                     VARCHAR2(30)
     
    SQL> SELECT to_lob(text) from all_views
      2  where rownum <= 1;
    SELECT to_lob(text) from all_views
           *
    FEHLER in Zeile 1:
    ORA-00932: inconsistent datatypes expected got LONG
    Does anyone have an idea?

    TO_LOB are usable in the SELECT an INSERT statement

    SQL> create table t
      2  (text clob)
      3  /
    
    Table created.
    
    SQL>
    SQL> insert into t
      2  SELECT to_lob(text) from all_views
      3   where rownum <= 1;
    
    1 row created.
    
    SQL>
    SQL> select *
      2    from t
      3  ;
    
    TEXT
    --------------------------------------------------------------------------------
    select "FILE#","BLOCK#","CLASS#","STATUS","XNC","FORCED_READS","FORCED_WRITES","
    
    {code}
    
    http://www.lc.leidenuniv.nl/awcourse/oracle/server.920/a96540/functions139a.htm                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
    
  • ORA-00932: inconsistent data types: expected - got NUMBER

    Hello
    in 10g R2:
    SQL> select count(*) from sysman.MGMT_METRICS_RAW;
    select count(*) from sysman.MGMT_METRICS_RAW
                                *
    ERROR at line 1:
    ORA-01578: ORACLE data block corrupted (file # 3, block # 27080)
    ORA-01110: data file 3: 'D:\BASE\DB\DATA\SYSAUX01.DBF'
    SQL> select * from sysman.MGMT_METRICS_RAW where rowid=27080;
    select * from sysman.MGMT_METRICS_RAW where rowid=27080
                                                     *
    ERROR at line 1:
    ORA-00932: inconsistent datatypes: expected - got NUMBER
    How to convert the rowid to be accepted in this query?
    Thank you

    This isn't the rowid. This is the block #.

  • ORA-00932: inconsistent data types: expected - was -.

    DECLARE
    STR VARCHAR2(2000):='<SerachVal>1234</SerachVal>';
    L_OUT VARCHAR2(1000);
    BEGIN
    SELECT EXTRACTVALUE(STR,'/SerachVal') INTO L_OUT FROM DUAL;
    DBMS_OUTPUT.PUT_LINE(L_OUT);
    END;
    
    
    error:
    
    PL/SQL: ORA-00932: inconsistent datatypes: expected - got -
    PL/SQL: SQL Statement ignored
    06550. 00000 -  "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    SQL> set serverout on
    SQL> DECLARE
      STR   VARCHAR2(2000):='1234';
      L_OUT VARCHAR2(1000);
    BEGIN
      SELECT EXTRACTVALUE(XMLTYPE(STR),'/SerachVal') INTO L_OUT FROM DUAL;
      DBMS_OUTPUT.PUT_LINE(L_OUT);
    END;  2    3    4    5    6    7
      8  /
    1234
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    
  • [8i] Case statement generates ORA-00932: inconsistent data types

    Note: I work with a 8i database (Yes, he's old enough) and in this case, I have to deal with the types of data (e.g. TANK), I gives me to work with.

    I am trying to calculate the amount of time product expected between manufacturing steps. As I found out though, sometimes I get a negative value then subtract the date the previous step ends the date of that ongoing stage begins. Since it is generally impossible to start a later stage before a previous step (imagine trying to screw a cap on a bottle that has no son Cup yet - it just may not happen), what I found is that sometimes two steps are started the same day and finished the same day (although not necessarily the day they started). This situation CAN occur when a person is two steps and connected to two steps at the same time, rather than log on to one, then the other. So what I need to do in these situations, is to replace the negative number by zero (I'll treat the stage as having no time-out).

    Some examples of data:
    (Note: the data set real is the result of a query and has about 200 K lines and columns more, but this should be representative enough to find a solution that works on my real 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's the query I use that sometimes returns negative values:
    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.000
    These 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.000
    And that's what I tried to do to get these results (comment pointed out which line has 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 that I had errors in data type incompatible before with case statements in this particular 8i database, but I can't seem to understand why I'm getting one this time. I think it has something to do with the NULL value which may 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 works fine. But, I'm not NULL, I 0. In the level of this request, I'll take the averages by item_id/step_nbr, and I want that 0 s to be included in the average. (NULL values, as far as I know, would be excluded. AVG(null,_1,_2) = AVG (1,2) = 1.5 NOT AVG (0,1,2) = 1).

    Thanks in advance!

    CASE requires that all expressions to be of the same type. Numeric data type code is 2, then that date produced different internal datatype 14:

    SQL> select dump(1) a,dump(sysdate) b,dump(sysdate - (sysdate - 1)) c from dual;
    
    A                  B                                   C
    ------------------ ----------------------------------- ------------------------------
    Typ=2 Len=2: 193,2 Typ=13 Len=8: 219,7,6,27,13,7,50,0  Typ=14 Len=8: 1,0,0,0,0,0,0,0
    
    SQL> 
    

    Case is supposed to process until the number, but it does not--a bug in some versions. Use explicit to_number:

    ,     CASE
              WHEN     start_dt - last_step_finished     < 0
              THEN     0
              ELSE     to_number(start_dt - last_step_finished)
         END                         AS days_in_queue
    

    SY.

  • SQL error: ORA-00932: inconsistent data types: expected - was -.

    Hello
    When I am tring to run under sql statement I ORA-00932.

    Select extractvalue ("< rrr > 13 < /rrr > ',' / rrr'") twice;

    How to extract this value?

    Select extractvalue (XMLTYPE ('13'),'/ rrr') twice;

  • ORA-00932: inconsistent data types: expected DATE got the NUMBER

    SELECT DISTINCT NVL (jtf.NAME, 'No Sales Credit') NAME, ract.customer_trx_id,
                    ract.trx_number, ract.bill_to_customer_id,
                    NVL (ract.primary_salesrep_id, -3) primary_salesrep_id,
                    rac.customer_name custname,
                    /*xx_nyl_sa_order_type
                                           (NVL (ract.ship_to_site_use_id,
                                                 ract.bill_to_site_use_id
                                                ),
                                            DECODE (ract.ship_to_site_use_id,
                                                    NULL, 'B',
                                                    'S'
                                                   )
                                           ) S_TYPE,RACTL.INTERFACE_LINE_ATTRIBUTE2,*/
                    xx_nyl_cust_address
                                       (NVL (ract.ship_to_site_use_id,
                                             ract.bill_to_site_use_id
                                            ),
                                        DECODE (ract.ship_to_site_use_id,
                                                NULL, 'B',
                                                'S'
                                               )
                                       ) address,
                      NVL (ractl.extended_amount, 0)
                    * NVL (ract.exchange_rate, 1) itm_sales,
                      NVL (ractl.quantity_invoiced, 0)
                    + NVL (ractl.quantity_credited, 0) qty,
                    item_dtl.itemid itemid, item_dtl.itemno itemno,
                    item_dtl.segment2, item_dtl.segment3,
                    item_dtl.attribute7 attribute7,
                    item_dtl.attribute8 attribute8,
                    item_dtl.attribute12 attribute12, item_dtl.itemdesc itemdesc,
                    ractl.inventory_item_id invid,
                --ract.ship_to_site_use_id,
    --                ract.bill_to_site_use_id,
                                                  ractl.customer_trx_line_id
               FROM ra_customer_trx_all ract,
                    ra_customer_trx_lines_all ractl,
                    jtf_rs_salesreps jtf,
                    ra_customers rac,
                    ra_cust_trx_types_all ractt,
                    hr_all_organization_units hr,
                    (SELECT DISTINCT iim.item_id itemid,
                                     msi.inventory_item_id invid,
                                     iim.item_no itemno,
                                     stk_dtl.segment2 segment2,
                                     stk_dtl.segment3 segment3,
                                     iim.attribute7 attribute7,
                                     iim.attribute8 attribute8,
                                     iim.attribute12 attribute12,
                                     iim.item_desc1 itemdesc
                                FROM ic_item_mst iim,
                                     mtl_system_items_b msi,
                                     (SELECT mtl.segment2, mtl.segment3,
                                             gmi.item_id
                                        FROM mtl_categories_b mtl,
                                             fnd_id_flex_structures_vl fndi,
                                             gmi_item_categories gmi
                                       WHERE gmi.category_id = mtl.category_id
                                         AND fndi.id_flex_structure_name =
                                                                      'Item Group'
                                         AND fndi.id_flex_num = mtl.structure_id) stk_dtl
                               WHERE iim.item_no = msi.segment1
                                 AND stk_dtl.item_id = iim.item_id) item_dtl
              WHERE ract.customer_trx_id = ractl.customer_trx_id
                AND ractl.line_type = 'LINE'
                AND ract.cust_trx_type_id = ractt.cust_trx_type_id
                AND hr.organization_id = ractl.org_id
                AND JTF.ORG_ID = RACT.ORG_ID
    --       AND ractl.inventory_item_id = 8880
                AND item_dtl.invid = ractl.inventory_item_id
                AND ractt.default_status NOT LIKE 'VD'
                AND ractl.inventory_item_id IS NOT NULL
                AND jtf.salesrep_id(+) = ract.primary_salesrep_id
                AND rac.customer_id = ract.bill_to_customer_id
                AND NVL
                       (ractl.interface_line_attribute2,
                        NVL
                           (xx_nyl_sa_order_type
                                                (NVL (ract.ship_to_site_use_id,
                                                      ract.bill_to_site_use_id
                                                     ),
                                                 DECODE (ract.ship_to_site_use_id,
                                                         NULL, 'B',
                                                         'S'
                                                        )
                                                ),
                            'Order'
                           )
                       ) =
                       NVL
                          (:p_sales_type,
                           NVL
                              (ractl.interface_line_attribute2,
                               NVL
                                  (xx_nyl_sa_order_type
                                                (NVL (ract.ship_to_site_use_id,
                                                      ract.bill_to_site_use_id
                                                     ),
                                                 DECODE (ract.ship_to_site_use_id,
                                                         NULL, 'B',
                                                         'S'
                                                        )
                                                ),
                                   'Order'
                                  )
                              )
                          )
                AND NVL (jtf.NAME, 'No Sales Credit')
                       BETWEEN NVL (:p_salesmen_from,
                                    NVL (jtf.NAME, 'No Sales Credit')
                                   )
                           AND NVL (:p_salesmen_to,
                                    NVL (jtf.NAME, 'No Sales Credit')
                                   )
                AND rac.customer_name BETWEEN NVL (:p_customer_from,
                                                   rac.customer_name
                                                  )
                                          AND NVL (:p_customer_to,
                                                   rac.customer_name
                                                  )
                AND trunc(ract.trx_date) BETWEEN trunc(:p_year_from) AND trunc(:p_year_to)

    user9093700 wrote:

    TRUNC(ract.trx_date, 'YYYY') between :p_year_from and :p_year_to
    

    ORA-01843: not one month valid

    Well, you won't get definitive answers unless you provide the requested information.
    What type of p_year_from and data p_year_to?
    Guessing based on your last two answers, it is VARCHAR2, isn't it?
    Convert to date and compare:

    trunc(ract.trx_date) between to_date(:p_year_from,'DD/MM/YYYY') AND to_date(:p_year_to,'DD/MM/YYYY')
    

    That said, store dates as string is a major shortcoming. Consider to store and maintain dates in the form of dates.

Maybe you are looking for