ORA-00932 error

Dear all,
I am getting the following error when i try to compile a package body.
The following error has occurred:
PACKAGE BODY BTPL.STOCK
On line: 27
PL/SQL: ORA-00932: inconsistent datatypes: expected NUMBER got -
Details:
PACKAGE BODY BTPL.STOCK
On line: 27
PL/SQL: ORA-00932: inconsistent datatypes: expected NUMBER got -
can someone finds me the solution for the issue posted.
Thanks in Advance.
Nirmal

The following is the code
CREATE OR REPLACE PACKAGE BODY STOCK
IS
PROCEDURE POPULATE_OPENING_BALANCE(GivenDate in Varchar2)
IS
BEGIN
delete from STOCK_TEMP_OPEN_BALANCE;
FOR I IN
select
     nvl(a.cst_material,b.cst_material) temp_material,
     nvl(a.cst_receiving_vendor,b.cst_receiving_vendor) temp_vendor,
     nvl(cst_quantity,0) temp_opening_balance,
     (nvl(received_qty,0)-nvl(cst_quantity,0)) received_qty,
     nvl(consumed_qty,0) consumed_qty,
     (nvl(received_qty,0)- nvl(consumed_qty,0)) stock_qty,
     a.uom uom
from
     select
          nvl(r.cst_material,c.cst_material) cst_material,
          nvl(r.cst_receiving_vendor,c.cst_receiving_vendor) cst_receiving_vendor,
          nvl(r.received_qty,0) received_qty,
          nvl(c.consumed_qty,0)consumed_qty,
          r.uom uom
     from
          SELECT
               lpad(cst_material,18,0) cst_material,
               cst_receiving_vendor,
               (SUM (cst_quantity)) received_qty,
               unit_of_measure uom
          FROM
               select
                    lpad(cst_material,18,0) cst_material,
                    cst_receiving_vendor,
                    cst_quantity,
                    CST_UNIT_OF_MEASURE unit_of_measure
               from
                    STOCK_DATA c
               WHERE
                    (cst_doc_date between to_date('26/11/2006','dd/mm/yyyy') and (to_date(GivenDate,'dd/mm/yyyy')))
                    and ((CST_MOVEMENT_TYPE='101' and CST_SPL_INDICATOR ='O')
                         or CST_MOVEMENT_TYPE='541'
                         or CST_MOVEMENT_TYPE='544'
                         or CST_MOVEMENT_TYPE='545'
                         or (CST_MOVEMENT_TYPE='552' and CST_SPL_INDICATOR ='O'))
               union all
                    select
                         lpad(temp_material,18,0)
                         cst_material,temp_vendor cst_receiving_vendor,
                         temp_opening_balance cst_quantity,
                         temp_uom unit_of_measure
                    from
                    STOCK_OPEN_BALANCE_261106
          group by cst_material,cst_receiving_vendor,unit_of_measure
     )r
     full outer join
          select
               lpad(cst_material,18,0) cst_material,
               cst_receiving_vendor,
               (SUM (cst_quantity)) consumed_qty,
               CST_UNIT_OF_MEASURE uom
          from
               STOCK_DATA
          where
               (cst_doc_date between to_date('26/11/2006','dd/mm/yyyy')
               and (to_date(GivenDate,'dd/mm/yyyy')))
               and (CST_MOVEMENT_TYPE='543'
                    or CST_MOVEMENT_TYPE='542'
                    OR CST_MOVEMENT_TYPE='546'
                    OR (CST_MOVEMENT_TYPE='102' and CST_SPL_INDICATOR ='O')
                    or (CST_MOVEMENT_TYPE='551' and CST_SPL_INDICATOR ='O'))
               GROUP BY cst_material,cst_receiving_vendor,CST_UNIT_OF_MEASURE
     )c
     on
     r.cst_receiving_vendor=c.cst_receiving_vendor
     and r.cst_material=c.cst_material
)a
full outer join
     select
          lpad(temp_material,18,0) cst_material,
          temp_vendor cst_receiving_vendor,
          temp_opening_balance cst_quantity
     from
          STOCK_OPEN_BALANCE_261106
) b
on
a.cst_material = b.cst_material and
a.cst_receiving_vendor=b.cst_receiving_vendor
LOOP
INSERT INTO STOCK_TEMP_OPEN_BALANCE (TEMP_MATERIAL, TEMP_VENDOR,TEMP_OPENING_BALANCE, TEMP_RECEIVED_QTY, TEMP_CONSUMED_QTY, TEMP_STOCK_QTY,TEMP_UOM
VALUES
(I.TEMP_MATERIAL,I.TEMP_VENDOR,I.TEMP_OPENING_BALANCE,I.RECEIVED_QTY,I.CONSUMED_QTY,I.STOCK_QTY,I.UOM
END LOOP;
END POPULATE_OPENING_BALANCE;
------------------ END POPULATE_OPENING_BALANCE ------
PROCEDURE STOCK_ANALYSIS_DETAILED_REPORT(FromDate varchar2,ToDate varchar2)
AS
OPENING_BALANCE NUMBER:=0;
prev_vendor VARCHAR2(75) := 'NONE';
prev_material VARCHAR2(75) := 'NONE';
BEGIN
delete STOCK_ANALYSIS_TABLE;
FOR I IN
select
     cst_doc_no,
     cst_doc_date,
     cst_movement_type,
     cst_grgi_slip_no,
     cst_material,
     cst_receiving_vendor,
     received_qty,
     consumed_qty,
     status,
     NVL((SELECT TEMP_STOCK_QTY FROM STOCK_TEMP_OPEN_BALANCE WHERE TEMP_VENDOR= cst_receiving_vendor AND TEMP_MATERIAL=cst_material),0) OPENING_BALANCE,
     UOM,
     dc_no,
     dc_date,
     dc_doc_no
from
     (     select
               cst_doc_no,
               cst_doc_date,
               cst_movement_type,
               cst_grgi_slip_no,
               lpad(cst_material,18,0) cst_material,
               cst_receiving_vendor ,
               sum(cst_quantity) received_qty,
               0 consumed_qty,
               'received' status,
               cst_unit_of_measure UOM,
               dc_no dc_no,
               dc_date dc_date,
               dc_doc_no dc_doc_no
          from
               STOCK_DATA c
          WHERE
               (cst_doc_date between to_date(FromDate,'dd/mm/yyyy') and to_date(ToDate,'dd/mm/yyyy'))
               and (
                    (CST_MOVEMENT_TYPE='101' and CST_SPL_INDICATOR ='O') or
                    CST_MOVEMENT_TYPE='541' or
                    CST_MOVEMENT_TYPE='544' or
                    CST_MOVEMENT_TYPE='545' or
                    (CST_MOVEMENT_TYPE='552' and CST_SPL_INDICATOR ='O')
          group by
               cst_material,cst_receiving_vendor,cst_doc_date,cst_doc_no,cst_movement_type,
               cst_grgi_slip_no,cst_unit_of_measure,dc_no,dc_date,dc_doc_no
     UNION
          select
               cst_doc_no,
               cst_doc_date,
               cst_movement_type,
               cst_grgi_slip_no,
               lpad(cst_material,18,0) cst_material ,
               cst_receiving_vendor,
               0 received_qty,
               (SUM (cst_quantity)) consumed_qty,
               'consumed' status,
               CST_UNIT_OF_MEASURE UOM,
               dc_no dc_no,
               dc_date dc_date,
               dc_doc_no dc_doc_no
          from
               STOCK_DATA
          where
               (cst_doc_date between to_date(FromDate,'dd/mm/yyyy') and to_date(ToDate,'dd/mm/yyyy'))
               and (CST_MOVEMENT_TYPE='543'
               or CST_MOVEMENT_TYPE='542'
               OR CST_MOVEMENT_TYPE='546'
               OR (CST_MOVEMENT_TYPE='102' and CST_SPL_INDICATOR ='O')
               or (CST_MOVEMENT_TYPE='551' and CST_SPL_INDICATOR ='O'))
          group by
               cst_material,cst_receiving_vendor,cst_doc_date,cst_doc_no,cst_movement_type,
               cst_grgi_slip_no,cst_unit_of_measure,dc_no,dc_date,dc_doc_no
order by cst_receiving_vendor,cst_material,cst_doc_date asc, status desc
LOOP
IF not(i.cst_receiving_vendor = prev_vendor AND i.cst_material = prev_material) THEN
OPENING_BALANCE := i.OPENING_BALANCE;
END IF;
INSERT INTO STOCK_ANALYSIS_TABLE
(CST_DOC_NO, CST_DOC_DATE, CST_MOVEMENT_TYPE,
CST_GRGI_SLIP_NO, CST_MATERIAL, CST_RECEIVING_VENDOR,
RECEIVED_QTY, CONSUMED_QTY, STATUS, OPENING_BALANCE, STOCK_QTY,
UOM, DC_NO, DC_DATE, DC_DOC_NO
VALUES
i.cst_doc_no,
i.cst_doc_date,
i.cst_movement_type,
i.cst_grgi_slip_no,
i.cst_material,
i.cst_receiving_vendor,
i.received_qty,
i.consumed_qty,
i.status,
OPENING_BALANCE ,
(OPENING_BALANCE+i.received_qty)-i.consumed_qty,
i.uom,
i.dc_no,
i.dc_date,
i.dc_doc_no
OPENING_BALANCE := (OPENING_BALANCE+i.received_qty)-i.consumed_qty;
prev_vendor := i.cst_receiving_vendor;
prev_material := i.cst_material ;
END LOOP;
END STOCK_ANALYSIS_DETAILED_REPORT;
------- END STOCK_ANALYSIS_DETYAILED_REPORT ------
PROCEDURE AGING_REPORT(GivenDate in Varchar2)
AS
vPrevVendor varchar2(25) := 'V';
vPrevMaterial varchar2(25) := 'M';
vCurrentVendor varchar2(25) := null;
vCurrentMaterial varchar2(25) := null;
vConsumedQty number:=0;
vStockQty number := 0;
vStockFlag varchar2(5) := 'Y';
vQtyFlag varchar2(5) := 'Y';
vCountFlag number := 0;
BEGIN
delete STOCK_AGING_TABLE;
FOR I IN (
select
CST_DOC_NO, CST_DOC_DATE, CST_MATERIAL, CST_RECEIVING_VENDOR, RECEIVED_QTY, CONSUMED_QTY, OPENING_BALANCE,
UOM,DC_NO,DC_DATE,DC_DOC_NO,CST_GRGI_SLIP_NO
from STOCK_ANALYSIS_TABLE
LOOP
     vCurrentVendor := I.CST_RECEIVING_VENDOR;
     vCurrentMaterial := I.CST_MATERIAL;
     IF vPrevVendor = i.CST_RECEIVING_VENDOR AND vPrevMaterial= i.CST_MATERIAL THEN
          IF vStockFlag='Y' THEN
          vStockFlag := 'N';
               FOR J IN(select CONSUMED_QTY from STOCK_ANALYSIS_TABLE
               WHERE CST_RECEIVING_VENDOR = i.CST_RECEIVING_VENDOR and CST_MATERIAL = i.CST_MATERIAL) LOOP
                    vConsumedQty := vConsumedQty+J.CONSUMED_QTY;
               END LOOP;
          vConsumedQty := ( vConsumedQty - (I.OPENING_BALANCE + I.RECEIVED_QTY));
          ELSIF vQtyFlag = 'Y' THEN
                    vConsumedQty := (vConsumedQty - I.RECEIVED_QTY);
          END IF;
          IF     vConsumedQty <= 0 THEN
               IF vQtyFlag = 'Y' THEN
               vQtyFlag := 'N';
               vStockQty := abs(vConsumedQty);
               ELSE
               vStockQty := I.RECEIVED_QTY;
               END IF;
               INSERT INTO STOCK_AGING_TABLE
               (SAT_DOC_DATE,SAT_DOC_NO,SAT_VENDOR,SAT_MATERIAL,SAT_STOCK_QTY,SAT_NO_OF_DAYS,SAT_UOM, SAT_DC_NO, SAT_DC_DATE, SAT_DC_DOC_NO,SAT_GR_GI_SLIP_NO)
               VALUES
               I.CST_DOC_DATE,I.CST_DOC_NO,I.CST_RECEIVING_VENDOR,I.CST_MATERIAL,vStockQty,(to_date(GivenDate,'dd/mm/yyyy') - I.CST_DOC_DATE),I.UOM,I.DC_NO,I.DC_DATE,I.DC_DOC_NO,I.CST_GRGI_SLIP_NO
          END IF;
     ELSIF(vPrevVendor <> vCurrentVendor AND vPrevMaterial <> vCurrentMaterial) THEN
               select count(CST_MATERIAL) into vCountFlag from STOCK_ANALYSIS_TABLE
               WHERE CST_RECEIVING_VENDOR = vCurrentVendor and CST_MATERIAL = vCurrentMaterial;
               IF vCountFlag = 1 THEN
               INSERT INTO STOCK_AGING_TABLE
               (SAT_DOC_DATE,SAT_DOC_NO,SAT_VENDOR,SAT_MATERIAL,SAT_STOCK_QTY,SAT_NO_OF_DAYS,SAT_UOM, SAT_DC_NO, SAT_DC_DATE, SAT_DC_DOC_NO,SAT_GR_GI_SLIP_NO)
               VALUES
               I.CST_DOC_DATE,I.CST_DOC_NO,I.CST_RECEIVING_VENDOR,I.CST_MATERIAL,(I.OPENING_BALANCE+I.RECEIVED_QTY),(to_date('31/03/2007','dd/mm/yyyy') - I.CST_DOC_DATE),I.UOM,I.DC_NO,I.DC_DATE,I.DC_DOC_NO,I.CST_GRGI_SLIP_NO
          vStockFlag := 'Y';
               vQtyFlag := 'Y';
               vConsumedQty := 0;
               END IF;
     ELSE
          vStockFlag := 'Y';
               vQtyFlag := 'Y';
               vConsumedQty := 0;
     END IF;
vPrevVendor := I.CST_RECEIVING_VENDOR;
vPrevMaterial := I.CST_MATERIAL;
END LOOP;
END AGING_REPORT;
END STOCK;
/

Similar Messages

  • ORA-00932 error: limitations for SDO_UTIL.FROM_WKTGEOMETRY and SDO_GEOMETRY

    Hi all,
    In my project, I use C# .net and Oracle 11g. I use ADO.NET OracleClob object in my C# code which will be passed to a procedure (procedure defined in a package) where I convert the input clob/wkt geometry into SDO_GEOMETRY using SDO_UTIL.FROM_WKTGEOMETRY and subsequently the GEOMETRY can be pushed into a table as shown below.
    PROCEDURE insert_extent(p_key_id IN NUMBER, p_extent IN CLOB) AS
    m_geom SDO_GEOMETRY;
    BEGIN
    m_geom := SDO_UTIL.FROM_WKTGEOMETRY(p_extent);
    UPDATE TEMP SET GEOM = m_geom
    WHERE IDS = p_key_id;
    COMMIT;
    END insert_extent;
    The above code is working fine for small size clob inputs, but, I have encountered ORA-00932 error when my clob/wkt geometry was more than 30MB in size.
    Can any one tell me what is the limitation of size of the clob to convert the CLOB to SDO_GEOMETRY and is there any limitaion on SDO_GEOMETRY datatype object to write the geometry into a table as well via insert/update statement.
    Also share your thoughts on how to resolve the issue.
    Please let me know if further information is required and thanks for the help in advance.
    Regards,
    Kumar

    MDSYS.SDO_ORDINATE_ARRAY in sdo_geometry can hold 1048576 numbers:
    desc MDSYS.SDO_ORDINATE_ARRAY
    MDSYS.SDO_ORDINATE_ARRAY VARRAY(1048576) OF NUMBER

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

  • XQSEQUENCEFROMXMLTYPE  -- ora-00932

    I was trying to view the trace file output of a session trace. Used TKPROF to read the trace file for me. This is a part of the file I found:
    SELECT XMLELEMENT("ISA", XMLAGG(T.COLUMN_VALUE))
    FROM
    XMLTABLE('/ISA/node()[ora:matches(name(),"ISA")]' PASSING :B1 ) T
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.01       0.00          0          0          0           0
    Execute      1      0.03       0.15          4        271          0           0
    Fetch        1      0.00       0.02          0         16          0           1
    total        3      0.04       0.18          4        287          0           1
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 268  (XXDAN)   (recursive depth: 1)
    Rows     Row Source Operation
          1  SORT AGGREGATE (cr=10672 pr=226 pw=0 time=7785206 us)
         16   COLLECTION ITERATOR PICKLER FETCH XQSEQUENCEFROMXMLTYPE (cr=10656 pr=226 pw=0 time=7765080 us)
    error during execute of EXPLAIN PLAN statement
    ORA-00932: inconsistent datatypes: expected - got CHAR
    parse error offset: 184I am guessing this has something to do with the XQuery within the sql statement I had in there.
    Right after that , I had this piece of information:
    begin :1 := sys.dbms_xqueryint.getXQueryX(:2); end;
    call     count       cpu    elapsed       disk      query    current        rows
    Parse       20      0.00       0.00          0          0          0           0
    Execute     20      0.45       0.87          0        460        596          20
    Fetch        0      0.00       0.00          0          0          0           0
    total       40      0.45       0.87          0        460        596          20
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 268  (XXDAN)   (recursive depth: 2)Although I don't have the second piece of code in my procedure ( and I TKPROF'ed with sys=no), so, I am guessing that both the pieces are related. I could be totally wrong though.
    Anyway, I would like to know what happened here to give this ora-00932 error?
    Thank you for your consideration,
    Rahul.

    Invalid Month error in PL/SQL
    ¿what is fec_alta? I suppose is a type date
    Modify
    fmodif:=TO_DATE(fec_alta||' '||hor_alta,'DD/MM/YYYY HH24:MI:ss');
    For
    fmodif:=TO_DATE( to_char(fec_alta, 'DD/MM/YYYY') ||' '||hor_alta,'DD/MM/YYYY HH24:MI:ss');

  • Error ORA-00932 updating data in worksheet

    OK, some of this may be extraneous, but here goes:
    Using SQLDeveloper 1.5.1 Build MAIN-5440
    I needed to insert a couple of columns into the middle of a table, so I renamed, created, and copied. Both fields are FKs, but are initially null.
    So, I go into the data worksheet, change the value of one of them, and then use 'DELETE' to remove that value, and then hit commit, I get:
    One error saving changes to table "WWSEBS01"."WWT03495_PT_LKP":
    Row 1: ORA-00932: inconsistent datatypes: expected NUMBER got DATE
    Another user received "expected NUMBER got TIMESTAMP".
    This same operation works just fine on the other fields in the table.
    I'm still not sure if this is a feature or a bug. :)
    Any ideas?
    Michael

    Michael,
    I am getting exactly the same errors when trying to delete a value from a number datatype column using the worksheet.
    I'm also using SQLDeveloper 1.5.1 Build MAIN-5440 and the error given is...
    One error saving changes to table "xxxxxx"."xxxxxxx":
    Row 1: ORA-00932: inconsistent datatypes: expected NUMBER got DATE
    I can change the numeric value to a different non-null value fine and all the other non-number fields can be edited without error.
    There is also no issue with setting a numeric value to null using a standard SQL statement from the command line.
    This only affects a couple of my tables and maybe related to those where I have changed column names in the past week or so.
    I have checked out the xxxTableSettings.xml files but they look fine (i.e the right column names and order) for the affected tables.
    I will look further into this but has anyone else got any ideas.
    Cheers
    Alex

  • 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

  • A database error occured. The database error text is: ORA-00932: inconsiste

    Hi Experts,
    In WebI XI 3.1, i am getting this error when i run webi report against a derived table "A database error occured. The database error text is: ORA-00932: inconsistent datatypes: expected NUMBER got DATE ". The derived table is designed in such a way that it populates only last week data, however, the result populates data for last week and current week. For the current week, it shows date range from feb19 to feb25, so the data is not correct. how can i get rid of current week.

    Hello, the error means that it is pulling a field with DATE type instead of a number, you should convert the date to a number at universe or document level.

  • Error: PL/SQL ORA-00932 inconsistent datatype when using LONG value

    Good morning:
    I am using a work PL/SQL script where I am using a LONG value in a cursor. When I execute it, I am receiving:
    PL/SQL ORA-00932 inconsistent datatype:  expected NUMBER got LONG
    set serveroutput ON SIZE 1000000
    set heading off               
    set feedback off               
    set trimspool off              
    set echo off
    set term off                  
    set pagesize 0        
    SPOOL &so_outfile;
    DECLARE
      v_data_file          varchar2(30);
    --   v_sch_code            varchar2(10);
    --   v_instance_name       varchar2(10);
        ws_path            payroll.pybutfl.pybutfl_utl_file_path%TYPE;
        v_data_line           VARCHAR2 (2000)                              := NULL;
        fhandle_o             UTL_FILE.file_type;
        v_line_count          NUMBER                                       := 0;
        v_selected_count      NUMBER                                       := 0;
        v_error_count         NUMBER                                       := 0;
        v_written_count       NUMBER                                       := 0;
        v_error_text          VARCHAR2 (50)       := ' AMACONF_ERR: Unable to write the line. ';
        v_errm                VARCHAR2 (255);
        v_sqlerrm             VARCHAR2 (255);
        v_payment_type        VARCHAR2(10);
    CURSOR C1 IS
    select RTRIM
            AMRCONF_PIDM_ERR            ||'|'||
            AMRCONF_IDEN_CODE_ERR       ||'|'||
            AMRCONF_ENTRY_DATE_ERR      ||'|'||
            AMRCONF_CONFID_IND_ERR      ||'|'||
           *AMRCONF_COMMENT_ERR        ||'|'||*
            AMRSUBJ_SUBJ_CODE_ERR       ||'|'||
            ERROR_CODE                  ||'|'||
            ERROR_CODE_TEXT                 ) data_line
            from WSUALUMNI.AMRCONF_ERR;
    BEGIN
    DBMS_OUTPUT.put_line ('Program Generating AMACOMT Mass Update Error File ');
    IF UTL_FILE.is_open (fhandle_o)
        THEN  
       UTL_FILE.fclose (fhandle_o);
    END IF;
    /* Name The File Here */
    v_data_file := ('Amaconf_error.txt');
    SELECT RTRIM (pybutfl_utl_file_path)
          INTO ws_path
          FROM payroll.pybutfl;
          fhandle_o := UTL_FILE.fopen (ws_path, v_data_file, 'w');
          DBMS_OUTPUT.put_line ('UTLFILE file for this run is: ' || ws_path||'/'||v_data_file);
          v_written_count := 0;  
    FOR c1_rec IN C1 LOOP
          BEGIN
            v_selected_count := v_selected_count + 1;
            v_data_line := rtrim(c1_rec.data_line);
            UTL_FILE.put_line (fhandle_o, v_data_line);
            v_written_count := v_written_count + 1;
        EXCEPTION
         WHEN OTHERS
          THEN
           DBMS_OUTPUT.put_line (v_error_text);
           v_error_count := v_error_count + 1;
        END;
    END LOOP;
         DBMS_OUTPUT.put_line ('Number of Records Selected: ' || v_selected_count);
         DBMS_OUTPUT.put_line ('Number of Records Written: ' || v_written_count);
          IF UTL_FILE.is_open (fhandle_o)
          THEN
             UTL_FILE.fclose (fhandle_o);
          END IF;
    END;
    SPOOL OFF;If I comment out the "AMRCONF_COMMENT_ERR ||'|'||" line, then the script works fine. The table was created as:
    Create Table WSUALUMNI.AMRCONF_ERR
        AMRCONF_PIDM_ERR             NUMBER (8)    NOT NULL,
        AMRCONF_IDEN_CODE_ERR        VARCHAR2(5)   NOT NULL,
        AMRCONF_ENTRY_DATE_ERR       DATE          NOT NULL,
        AMRCONF_CONFID_IND_ERR       VARCHAR2(1),
        AMRCONF_COMMENT_ERR          LONG,         
        AMRSUBJ_SUBJ_CODE_ERR        VARCHAR2(5)   NOT NULL,
        ERROR_CODE                   VARCHAR2(12)  NOT NULL,
        ERROR_CODE_TEXT              VARCHAR2(50)  NOT NULL
    ); I don't get what is the problem here in the script.

    Hi,
    Feew suggestions
    1) LONG is a deprecated type hence if possible start working on changing that column
    2) CLOB will your preferred datatype over LONG.
    3) you cannot use RTRIM on long.
    here is a very quick example
    drop table h
    create table h (x long,y varchar2(100))
    select rtrim(x) from h
    select rtrim(y) from hSolution:
    [http://www.oracle.com/technology/oramag/code/tips2003/052503.html]
    need a better solution change the datatype to clob and
    drop table h
    create table h (x clob,y varchar2(100))
    select  dbms_lob.substr( x, 4000, 1 ) from h
    select rtrim(y) from hCheers!!!
    Bhushan

  • Error message - ORA-00932: inconsistent datatypes: expected CHAR got 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 RFA_FLAG data type is NUMBER(*,0)... i am displaying LSF and Non-LSF in the select list box , but i get the error ORA-00932: inconsistent datatypes: expected CHAR got NUMBER >
    I have created static LOV with LSF display 0 return
    NON-LSF display 1 return..
    Could any body please help me in truble shooting the error ? how do i convert datatype into number i dont have any privileges to make changes to the table...

    Are there multiple columns in the table you are using from your LOV?
    Your LOV select is:
    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)Maybe try this:
    select
    from   DW_RFA_JOBDATA
    where  FINISH_TIME >= :P1_START_DATE
    and FINISH_TIME < :P1_END_DATE
         AND TO_CHAR(RFA_FLAG) = DECODE(:P1_JOB_CLASSIFICATION,'0','LSF','1','NON-LSF',RFA_FLAG)

  • Sync error....ORA-00932 Inconsistent datatypes

    Hey all,
    I am getting the following error when syncing:
    MS-9109 n@86e554 (this seems to be random string) || ORA-00932: inconsistent datatypes
    Now, I've narrowed it down to the field that causes this error to occur. It is important to note that if I don't touch the field (just keep the initial value from the initial sync to 8.1.7, things sync fine.
    The error only occurs if I change the field value in 9iLite (which I am doing through me eVB app).
    In 9iLite it is defined as:
    Data_Type = Number, Len = 5, N = Y, Prec = 5, Scale = 4
    In 8.1.7 it is defined as:
    Data_type = Number (5,4) Null = N
    I'm not sure why in Lite null is Y and in 8.1.7 null is N. I just let Oracle create the lite tables based on my snapshot. At any rate, the field is not null.
    Does anyone have any thoughts? Does anyone know what the first part (MS-9109) of the error message is about? I can't find anything on it in Google.
    Thx.
    Darren

    Well,
    If fixed my problem. I just re-wrote the sql I had defined in the snapshot for the table in question. Still not sure why it didn't initally work as I didn't change the logic at all.
    Darren.

  • Why do I get this error? ORA-00932: inconsistent datatypes

    This is my stored procedure I've created to select only the exact amount of records per page for 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 paremeters:
    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 datatypes: expected - got -
    ORA-06512: at "SIM.SELECT_COMMAND", line 10
    ORA-06512: at line 4
    00932. 00000 - "inconsistent datatypes: expected %s got %s"
    >
    At first Oracle gave me an error because the numbers were not a string. Then I convert them into a string (with to_char) and Oracle is still not happy! Any ideas as to why this is happening?
    Thanks for any help that you can provide.

    You don't select into ref cursors, you open them:
    SQL> create table t(c varchar2(1));
    Table created.
    SQL> insert into t values ('a');
    1 row created.
    SQL> insert into t values ('b');
    1 row created.
    SQL> insert into t values ('c');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> create or replace
      2  procedure p (p_ref out sys_refcursor) as
      3  begin
      4     open p_ref for 'select c from t';
      5  end;
      6  /
    Procedure created.
    SQL> var results refcursor
    SQL> exec p(:results);
    PL/SQL procedure successfully completed.
    SQL> print results
    C
    a
    b
    c

  • 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

  • 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

Maybe you are looking for

  • How to print a formatted page in java?

    hi all i've made my simple application that writes and retrieves information to/from a database, and organizes them in reports now, i got to print these reports in formatted pages like, for example: title centered and bold first db record second db r

  • 2 internal hard drives Mac Pro Tiger Server

    I have a mac pro 10.4.11 server that has 2 internal hard drives. 1 is 232.89 GB which is the main startup drive and the second is 465.76 Gb which I had pre installed for extra storage. My question is when I look in Server Admin under sharing and I cl

  • Integration with homemade software

    I am building a content management system. There will be links to all of our files which can open any of them in a browser window. I would also like to be able to open a file in contribute, edit it, upload it, and exit contribute, but remain in the C

  • Trouble converting to allow clip speed adjustments

    In clip inspector, where I should be able to drag along the line to slow down/speed up any particular clip, its asking me to convert the clip. I click on that, and it shows IMovie working to convert the clip, but then still asks me to do so and doesn

  • Is it possible to do a L-Cut in iMovie for iOS?

    I would like to start the audio of the second clip at the end of the first clip. Is it possible to do such a L-Cut in iMovie on my iPad? Thanks for answers, Thomas