CASE STATEMENT ERRORS

Hi all,
I have created a PLSQL code which is as follows:
create or replace procedure case_statement is
pi constant number(9, 7) := 3.1415927;
area number(14, 2);
cursor rad_cursor is
select * from radius_vals;
rad_val rad_cursor%rowtype;
begin
open rad_cursor;
loop
fetch rad_cursor
into rad_val;
exit when rad_cursor%notfound;
area := pi * power(rad_val.radius, 2);
case
when rad_val.radius = 3 then
insert into areas_case values (rad_val.radius, area);
when rad_val.radius = 4 then
insert into areas_case values (rad_val.radius, area);
when rad_val.radius = 10 then
insert into areas_case values (0, 0);
else
raise CASE_NOT_FOUND;
end case;
end loop;
close rad_cursor;
end case_statement;
When I execute this code I get these error messages:
ORA - 06592: CASE not found while executing CASE statement.
ORA - 06512: at "SCOTT.CASE_STATEMENT" line 24
ORA - 06512: at line 3
How do I resolve this problem?

How do I resolve this problem? Well your code raise CASE_NOT_FOUND in the else clause. So either do something different rad_val.radius is not equal to any of the tested values or give your code an exception handler.
Cheers, APC

Similar Messages

  • Case Statement error in Obiee

    Hi All,
    I'm facing an error with my Case statement in OBIEE(using it in expression builder in RPD). Below is the statement.
    CASE WHEN"GCRMANDB".""."HIM_SRV_REQ_DIM"."ATTRIB_44" = 'Customer Demand Not In GDMS' OR GCRMANDB"."HIM_SRV_REQ_DIM"."ATTRIB_45" = 'Customer Demand Not In GDMS' THEN 1
    (WHEN "GCRMANDB".""."HIM_SRV_REQ_DIM"."ATTRIB_44" = 'Poor Behaviour / Attitude' OR GCRMANDB"."HIM_SRV_REQ_DIM"."ATTRIB_45" = 'Poor Behaviour / Attitude' THEN 1) ELSE 0 END
    Error message that i'm getting is:
    [nQSError: 27002] Near <">: Syntax error [nQSError: 26012] .
    Plaese help

    Try this
    CASE
    WHEN "GCRMANDB"."HIM_SRV_REQ_DIM"."ATTRIB_44" = 'Customer Demand Not In GDMS' OR GCRMANDB"."HIM_SRV_REQ_DIM"."ATTRIB_45" = 'Customer Demand Not In GDMS' THEN 1
    WHEN "GCRMANDB"."HIM_SRV_REQ_DIM"."ATTRIB_44" = 'Poor Behaviour / Attitude' OR GCRMANDB"."HIM_SRV_REQ_DIM"."ATTRIB_45" = 'Poor Behaviour / Attitude' THEN 1
    ELSE 0 END
    Mark if helps

  • CASE Statement error in function -- Please help!

    Hi All,
    I created a function in my report.
    It has a SQL query similar to the one below. The query works fine in SQL plus.
    It has a CASE statement. I am getting error at line4 at the select statement. Error is: "Encountered symbol 'SELECT'....."
    Can we use CASE statements like this in reports that use SELECT statements for RETURN EXPRESSIONS. Do we have to do any special?
    Can someone help me out of this trouble?
    THanks in advance.
    SELECT PARENT_id,
         CASE WHEN EXISTS (SELECT PARENT_id FROM CHILD CH1 WHERE CH1.PARENT_id = PARENT.PARENT_id AND UPPER(CH1.description) LIKE '%ABC%') THEN
              (SELECT CH2.MOD_id FROM CHILD CH2 WHERE CH2.PARENT_id = PARENT.PARENT_id AND UPPER(CH2.description) LIKE '%ABC%')
         ELSE
              (SELECT MOD_id FROM
              (SELECT MOD_id,PARENT_id FROM CHILD CH3 ORDER BY started) MOD2 WHERE MOD2.PARENT_id = PARENT.PARENT_id AND ROWNUM = 1
         END
    ) MOD_ID
    FROM PARENT;

    take out the parentheses after the PARENT_ID and see
    like below
    SELECT parent_id,
           CASE
              WHEN EXISTS (
                     SELECT parent_id
                       FROM CHILD ch1
                      WHERE ch1.parent_id = PARENT.parent_id
                        AND UPPER (ch1.description) LIKE '%ABC%')
                 THEN (SELECT ch2.mod_id
                         FROM CHILD ch2
                        WHERE ch2.parent_id = PARENT.parent_id
                          AND UPPER (ch2.description) LIKE '%ABC%')
              ELSE (SELECT mod_id
                      FROM (SELECT   mod_id, parent_id
                                FROM CHILD ch3
                            ORDER BY started) mod2
                     WHERE mod2.parent_id = PARENT.parent_id AND ROWNUM = 1)
           END AS mod_id
      FROM PARENT;       

  • Case statement error OBIEE

    Hi All,
    I'm getting an error with my Case statement in OBIEE. Below is the statement.
    case when @{PV_RELEASE_NAME} = 'January' then "Script Details"."Calendar Date" is between ('1/1/2012','1/31/2012') else"Script Details"."Calendar Date" end
    Please advice. Thanks for your help in advance!

    Thanks for the response , I tried with the formula u mention still I am getting the same error ..Please find the error below
    case when @{PV_RELEASE_NAME} = 'January' then "Script Details"."Calendar Date" || " is between ('1/1/2012','1/31/2012')" else"Script Details"."Calendar Date" end
    Formula syntax is invalid.
    [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 27005] Unresolved column: " is between ('1/1/2012','1/31/2012')". (HY000)
    SQL Issued: SELECT case when 0 = 'January' then "Script Details"."Calendar Date" || " is between ('1/1/2012','1/31/2012')" else"Script Details"."Calendar Date" end FROM "Test Script - Ad Hoc"
    If I use the below formula I am getting syntax error
    case when @{PV_RELEASE_NAME} = 'January' then "Script Details"."Calendar Date" is between ('1/1/2012','1/31/2012') else"Script Details"."Calendar Date" end
    Formula syntax is invalid.
    [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 27002] Near : Syntax error [nQSError: 26012] . (HY000)
    SQL Issued: SELECT case when 0 = 'January' then "Script Details"."Calendar Date" is between ('1/1/2012','1/31/2012') else"Script Details"."Calendar Date" end FROM "Test Script - Ad Hoc"

  • Case statement error

    Error:  The below case statement is throwing error when i include in the select statement for B
       CASE WHEN (AST_INV_CHF_Y <= 250000)
                      THEN 'BELOW 250K'
                      WHEN (AST_INV_CHF_Y > 250000  AND AST_INV_CHF_Y <=1000000)
                      THEN 'CHF250K-1MN'
                      WHEN (AST_INV_CHF_Y > 1000000 AND AST_INV_CHF_Y <=5000000)
                      THEN 'CHF1MN-5MN'
                      WHEN (AST_INV_CHF_Y > 5000000 AND AST_INV_CHF_Y <=10000000)
                      THEN 'CHF5MN-10MN'
                      WHEN (AST_INV_CHF_Y > 10000000)
                      THEN 'CHF10MN PLUS'
                      ELSE 'NO INV HH AST' END AS AST_SGMT_RNG_CHF_T   
    ----------- Full query                 
    SELECT       TO_CHAR(SYSDATE,'yyyy-mm-dd') AS ED_UPD_D,
                 BRN_I,
                 DVS_I,
                 A.ACC_MHH_N,
                 GPC_MAND_C,
                 GPC_DPNT_C,          
                 GPC_INDEP_C, 
                 GPC_TRST_C,             
                 ACC_AST_PRCS_D,         
                 AST_SRCE_SD_Y,
                 AST_SRCE_SD_CHF_Y,
                 CNTRY_DMCL_DESC_T,
                 AST_SGMT_RNG_CHF_T
        select * from CFO_OWNER.ASSETS_BY_DOMICILE_TEMP1 A,
                 SELECT   SYSDATE    AS ED_UPD_D,
                              ACC_MHH_N,
                 SUM(
                         CASE WHEN (AST_GMIS_LIAB_C = '20001'
                        ) THEN AST_SRCE_SD_CHF_Y
                          ELSE 0 END)
                 AS AST_INV_CHF_Y ,
       CASE WHEN (AST_INV_CHF_Y <= 250000)
                      THEN 'BELOW 250K'
                      WHEN (AST_INV_CHF_Y > 250000  AND AST_INV_CHF_Y <=1000000)
                      THEN 'CHF250K-1MN'
                      WHEN (AST_INV_CHF_Y > 1000000 AND AST_INV_CHF_Y <=5000000)
                      THEN 'CHF1MN-5MN'
                      WHEN (AST_INV_CHF_Y > 5000000 AND AST_INV_CHF_Y <=10000000)
                      THEN 'CHF5MN-10MN'
                      WHEN (AST_INV_CHF_Y > 10000000)
                      THEN 'CHF10MN PLUS'
                      ELSE 'NO INV HH AST' END AS AST_SGMT_RNG_CHF_T           
        FROM CFO_OWNER.ASSETS_BY_DOMICILE_TEMP1
        GROUP BY ACC_MHH_N
        ORDER BY ACC_MHH_N
        ) B
    where a.ACC_MHH_N = b.ACC_MHH_N   )
    below are the columns for the table ASSETS_BY_DOMICILE_TEMP1.
                 A.ACC_MHH_N,
                 A.BRN_I,
                 A.DVS_I,
                 CNTRY_DMCL_DESC_T,
                 GPC_MAND_C,
                 GPCE_DPNT_C AS GPC_DPNT_C,      
                 GPC_INDEP_C, 
                 GPC_TRST_C,             
                 ACC_AST_PRCS_D,
                 AST_GMIS_LIAB_C,         
                 AST_SRCE_SD_Y,
                 AST_SRCE_SD_CHF_Y
        

    Hi,
    It's hard to tell if you have ENDs to each CASE.
    I recommend indenting so that the END comes directly underneath CASE, with only whitespace in between.
    SELECT  ED_UPD_D,ACC_MHH_N,AST_INV_CHF_Y ,
            CASE
           WHEN (AST_INV_CHF_Y <= 250000)
                      THEN 'BELOW 250K'
                      WHEN (AST_INV_CHF_Y <=1000000)  -- No need to test for lower bound
                      THEN 'CHF250K-1MN'
                      WHEN (AST_INV_CHF_Y <=5000000)
                      THEN 'CHF1MN-5MN'
                      WHEN (AST_INV_CHF_Y <=10000000)
                      THEN 'CHF5MN-10MN'
                      WHEN (AST_INV_CHF_Y > 10000000) -- Equivalent to IS NOT NULL
                      THEN 'CHF10MN PLUS'
                      ELSE 'NO INV HH AST'
         END AS AST_SGMT_RNG_CHF_T
    FROM (
         SELECT   TO_CHAR(SYSDATE,'yyyy-mm-dd')    AS ED_UPD_D,
                  ACC_MHH_N,
                       SUM (
                           CASE
                        WHEN (AST_GMIS_LIAB_C = '20001')
                        THEN AST_SRCE_SD_CHF_Y
                               ELSE 0
                   END
                   )             AS AST_INV_CHF_Y
         FROM      CFO_OWNER.ASSETS_BY_DOMICILE_TEMP1
             GROUP BY ACC_MHH_N
    ORDER BY ACC_MHH_NSince the first WHEN clause said
    AST_INV_CHF_Y <= 250000, there's no need to check for
    AST_INV_CHF_Y > 250000 in the second one: the second WHEN clause won't even be executed if AST_INV_CHF_Y <= 250000.
    Edited by: Frank Kulash on Nov 21, 2008 2:18 PM

  • Case Statement Error - Need help

    What's wrong with this case statement
    Case When Opportunity."Probability %" = '0' then "- Product Revenue"."Product Revenue (000)" *( Opportunity."Probability %" / 100) else "- Product Revenue"."Product Revenue (000)" *( "Opportunity - Product"."Probability %" / 100) end if
    I am getting an error when I place this in a pivot table

    Disregard, it is working now

  • Help: Case statement Error

    Hello Folks,
    Am trying to execute a procedure but somehow its returning an error near the case statement.I am thinking whether i have written it correctly or not. Can anyone please advice.Am just posting that specific part of the code where it points. Thanks a million.
    select  @v_retained_by_client = case c.code when '50' then RETAINED_BY_CLIENT  -- Its pointing the error at this line
                                                  when '51' then RETAINED_BY_CLIENT                
                                                  when '52' then RETAINED_BY_CLIENT
                                                  else 0
                                                  end,
               @v_hriretainedfee = case c.code  when '50' then hri_fee     
                                                when  '51' then hri_fee
                                                when '52' then hri_fee
                                                else 0
                                                end,
              @v_adminretainedfee = case c.code when '50' then admin_fee    
                                                when  '51' then admin_fee
                                                when '52' then admin_fee
                                                else 0
                                               end,  
               @v_allocation_amt = case c.code       when '50' then ALLOCATION_CHECK_AMOUNT
                                                        when '51' then ALLOCATION_CHECK_AMOUNT
                                                       when '52' then ALLOCATION_CHECK_AMOUNT          
                                                 else 0
                                              end,
              @v_cur_recoveryrefund = case c.code when '96' then sum(recovery_amount)      
              end,
              @v_cur_recoveryvoid = case c.code when '95'  then sum(recovery_amount)   
              end,
              @v_cur_hrirefund = case c.code when '96' then sum(hri_fee)            
              end,
              @v_cur_hrivoid = case c.code when '95'  then sum(hri_fee)             
              end,
                @v_cur_adminrefund = case c.code when '96' then sum(admin_fee)            
              end,
              @v_cur_adminvoid = case c.code when '95'  then sum(admin_fee)              
              end,
                @v_cur_taxrefund = case c.code when '96' then sum(taxes)             
              end,
              @v_cur_taxvoid = case c.code when '95' then sum(taxes)              
              end
                 from cash_receipt b, recovery_type c
                 where case_id = @v_case_id
              and b.recovery_type_id = c.recovery_type_id
              and recovery_date between @p_startdate and @p_enddate
            end         Edited by: user11961230 on Nov 25, 2009 1:27 PM

    Hi,
    Sorry, I don't know anything about SQL Server.
    I do know you should take baby steps, especially when trying something you're not sure how to do.
    Get rid of all but one CASE expression, until you know how to make that one work.
    When you do get that to work, add one more, as much like the first as possible, to make sure you know how to do two columns in the same query.
    Get asomething working, then try adding a little bit to it. When you do have errors, you'll have a much better idea what caused the errror.
    It's suspicious that you're using aggregate functions in some places, like this
    @v_cur_recoveryrefund = case c.code when '96' then sum(recovery_amount)      
              end,but not in the first CASE expressions. You might try <tt>MAX (CASE case c.code when '50' then ... END)</tt>
    I also find it odd that you're using <tt>CASE ... SUM (...)</tt> ; in Oracle, that would be very rare. It implies that the same expression will be in the GROUP BY clause.
    It's more common to have <tt>SUM (CASE ... END)</tt> , like this:
    SUM ( CASE c.code WHEN '96' THEN recovery_amount END )

  • Case statement error in 9i

    The following 2 queries gives me different result on running.. can anyone tell me the reason behind it.. is it a oracle error. Case statement gives me a additional unknown value..its not a null or a blank..why is it so?
    1)
    select DISTINCT case when X = 'Cluster' then Yend
    from TABLE_NAME
    2)
    SELECT DISTINCT Y FROM TABLE_NAME WHERE
    X = 'Cluster'

    Because in (1) when X != 'Cluster' the CASE expression will resolve to NULL, thus you have an extra value in the set after the DISTINCT modifier is applied.
    In (2), the rows where X != 'Cluster' are omitted altogether.
    cheers,
    Anthony

  • MDX - Simple Case Statement

    For some reason I am getting an error on a Simple Case Statement
    Error (1260052) – Syntax error in input MDX query on line 2 at token ‘)’
    Case
    When IS(Time.[JAN]) THEN Time.[Feb]
    ELSE
    Missing
    End
    Any suggestions.

    Hi all,
    I have a similar problem as i'm not too sure about the correct syntax I should use
    CASE
    WHEN IS(Time.CurrentMember, Descendants[2007]) THEN .......
    ELSE
    MISSING
    END
    How do I incorporate the check for Time.CurrentMember = Descendants of 2007???
    Many thanks!

  • Please help: Case Statement - ORA-01722: invalid number Error

    Hi All,
    I'm trying to use Case statement to recode Cancelled statuses into two groups
    'Reject' if the difference between first date and last date is less than 29 and
    'Accept' if the difference between first date and last date is greater than 30
    Here is my 'test' data:
    STATUS     FIRST_DATE     LAST_DATE
    Transfer     10/08/2011     10/09/2011
    Mover     10/08/2011     15/09/2011
    Cancel     10/08/2011     16/09/2011
    Cancel     10/08/2011     5/09/2011
    Here is the syntax
    select a.*,
    (CASE WHEN a.STATUS ='Cancel' THEN (round(a.LAST_DATE-a.FIRST_DATE))
    ELSE 0
    END) CAN_DAYS,
    (CASE WHEN 'CAN_DAYS' >29 THEN 'Reject'
    WHEN 'CAN_DAYS' <30 THEN 'Accept'
    END) Reject_Accept
    from test a
    The first CASE statement works fine and gives me this
    STATUS     FIRST_DATE     LAST_DATE     CAN_DAYS
    Transfer     10/08/2011     10/09/2011     0
    Mover     10/08/2011     15/09/2011     0
    Cancel     10/08/2011     16/09/2011     37
    Cancel     10/08/2011     5/09/2011     26
    but the second CASE produces ORA-01722: invalid number Error. It is something to do with the CAN_DAYS data type, Oracle doesn't see it as Numeric i think.
    The result i want to see would be
    STATUS     FIRST_DATE     LAST_DATE     CAN_DAYS Reject_Accept
    Transfer     10/08/2011     10/09/2011     0
    Mover     10/08/2011     15/09/2011     0
    Cancel     10/08/2011     16/09/2011     37 Accept
    Cancel     10/08/2011     5/09/2011     26 Reject
    Could someone please help me to fix the syntax?
    Thank you in advance,

    This seems to give you your desired results...
    with test as
      ( select 'Transfer' as status, to_date('10/08/2011') as first_date, to_date('10/09/2011') as last_date  from dual union all
        select 'Mover'             , to_date('10/08/2011')              , to_date('15/09/2011')               from dual union all
        select 'Cancel'            , to_date('10/08/2011')              , to_date('16/09/2011')               from dual union all
        select 'Cancel'            , to_date('10/08/2011')              , to_date('05/09/2011')               from dual
    select  status
         ,  first_date
         ,  last_date
         ,  CAN_DAYS
         ,  CASE
              WHEN CAN_DAYS =   0 THEN NULL
              WHEN CAN_DAYS <  30 THEN 'Reject'
              WHEN CAN_DAYS >= 30 THEN 'Accept'
            END  Reject_Accept
      from  ( select  status
                   ,  first_date
                   ,  last_date
                   ,  CASE
                        WHEN STATUS ='Cancel' THEN round(LAST_DATE-FIRST_DATE)
                        ELSE 0
                      END  CAN_DAYS
                from  test
    ;

  • Bind Variable In Case Statement Produces Error ORA-01036

    When running the following command using ODP.Net 10.1.0.301 I recieve error 1036. Statement runs fine within SQL+ and Toad.
    Dim SQL As String = "SELECT CASE WHEN EXISTS(SELECT part_nbr FROM item_master WHERE part_nbr=:part_number) THEN 1 ELSE 0 END AS RECORD_EXISTS FROM Dual"
    Dim OraConnection As New OracleConnection(connectstring)
    Dim OraCommand As New OracleCommand(SQL, OraConnection)
    OraCommand.Parameters.Add("part_number", OracleDbType.Varchar2).Value = PartNumber
    Dim Obj as Object=OraCommand.ExecuteScalar

    Hi Michael,
    I was able to get your code to work on my system by changing the SQL statement as follows:
    SELECT (CASE WHEN EXISTS(SELECT part_nbr FROM item_master WHERE part_nbr=:part_number) THEN 1 ELSE 0 END) AS RECORD_EXISTS FROM Dual
    I simply enclosed the case statement in opening and closing parenthesis...
    Hope that helps,
    - Mark

  • Creating view containing case statements received error ORA-22992

    We have a create view referencing table through dblink. The select statement in the create view has case statements, when running the Select statement alone, results are return. However, when executing the create view, it returns:
    SQL Error: ORA-22992: cannot use LOB locators selected from remote tables
    22992. 00000 - "cannot use LOB locators selected from remote tables"
    *Cause:    A remote LOB column cannot be referenced.
    *Action:   Remove references to LOBs in remote tables.
    One of the source table has LOB column but not in the select statement. The strange thing is when removing the case statement from the select, create view works fine. Can anybody tell me what caused the error and how to fix it?
    Create View Snippet:
    CREATE OR REPLACE VIEW "ABC"."XYZ" (....
    AS SELECT
    CASE
    WHEN A.OUTAGE =1
    THEN 'Y'
    ELSE 'N'
    END AS OUTAGE,
    FROM
    TABLEA@XXXX A
    LEFT JOIN TABLEB@XXXX B
    ON
    A.LOC =B.LO
    AND A.SITE =B.SITE
    WHERE
    A.CLASS ='CUSTOMER'
    AND A.PLUSSISGIS =1;

    What is your 4 digit Oracle version?
    Try rewriting the query to not use ANSI SQL92 joins. I found a link where this solved a problem similar to yours.
    DBLink problem ORA-22992
    >
    But, look at this curious thing: I re-write the query as follows:
    SELECT A.ID, A.ID_REF, A.EVENDATE, B.DESCRIPTION
    FROM A@ORCL A, B@ORCL B
    WHERE A.ID_REF = B.ID_REF;
    and it works fine... It seems like Oracle don't like the ANSI SQL92...
    >
    Several similar links by googling: 'SQL Error: ORA-22992'
    http://www.dbuggr.com/smallwei/solution-error-ora-22992-lob-locators-selected-remote-tabl/
    >
    Fixing ORA-22992 “cannot use LOB locators selected from remote tables” error
    You have migrated your Oracle 9i database to 10g and a distributed statement which worked fine in 9i now is getting error ORA-22992 “cannot use LOB locators selected from remote tables”. Even though the related remote table(s) does not contain any LOB column datatype.
    FIX:
    There is a bug on 9i,10g, and 11g that is related to this error. It is being fixed in 11.2. It can also be backported for previous 9i, 10g and 11g releases under the latest patchsets.
    You may also do a workaround as follow:
    Modify the affected SQL by adding the TO_CHAR function. For example:
    -- Original SQL:
    SELECT NVL2('a', 'b','c' ) FROM dual@remote_db;
    -- Modified SQL:
    SELECT TO_CHAR(NVL2('a','b','c')) FROM dual@remote_db;
    >
    See if that helps.

  • Error in writing case statement

    i am writing this getting error in case statement
    declare
    v_RenewService NUMBER(10,0);
    begin
    Select
    Case v_RenewService
    when
    5 >= 365 THEN
    when
    1=0
    then
    1
    else
    0
    end
    end
    from dual ;
    end;
    Error report:
    ORA-06550: line 7, column 3:
    PL/SQL: ORA-00905: missing keyword
    ORA-06550: line 5, column 1:
    PL/SQL: SQL Statement ignored
    06550. 00000 - "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    *Action:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Not clear what are you trying to do, but based on two ENDs it looks like code is missing second CASE:
    Select  case v_RenewService
              when 5 >= 365 THEN CASE
                                   when 1=0 then 1
                                   else 0
                                 end
            end
    from dual ;However the above is still wrong syntax since you can't mix simple_case_expression and searched_case_expression (see CASE Expressions). So please explain in words what are you trying to do.
    SY.

  • Case statement for interactive report error

    The case computation does not work for me :
    statement
    CASE WHEN G = 7 THEN G ELSE C END
    Error message ' Invalid computation expression. THEN'
    It does not seem to matter what the case statement is IE :
    CASE WHEN I = 'DEMO' THEN 'LOW' ELSE 'HIGH' END
    I have tried this on the Sample Application that is installed on my oracle workspace account
    Column G : order number ( number)
    Column C:order total (Number)
    Column I:sales Rep ( String)
    Can someone please tell me what I am doing wrong ?
    Thanks

    Your statement works for me exactly as you typed it:
    SQL> select * from t;
                       G                    C
                       1                  101
                       2                  102
                       3                  103
                       4                  104
                       5                  105
                       6                  106
                       7                  107
    7 rows selected.
    SQL> select CASE WHEN G = 7 THEN G ELSE C END
      2  from   t;
    CASEWHENG=7THENGELSECEND
                         101
                         102
                         103
                         104
                         105
                         106
                           7
    7 rows selected.

  • Help! This is driving me crazy. CASE statement report syntax error (missing operator)

    Hi
    Can anyone help with this SQL statement please. It uses a
    CASE statement but I keep getting back a syntax error (missing
    operator) error message. The SQL statement works without the CASE
    statement, so everything else is fine - its just when I put the
    CASE statement back in.
    Here's the SQL statement:-
    SELECT transactions.ourRef, transactions.transDate, CASE WHEN
    transactions.transTypeID = 2 THEN transactionDetails.goodsVatable *
    -1 ELSE transactionDetails.goodsVatable END,
    transactionDetails.goodsNonVat, transactionDetails.VAT,
    transactionDetails.grandTotal, clients.clientCode,
    transTypes.transTypeDesc
    FROM transactions, transactionDetails, clients, transTypes
    WHERE transactions.transID = transactionDetails.transID
    AND transactions.clientID = clients.clientID
    AND transactions.transTypeID = transTypes.transTypeID
    TransID = 2 means that its a credit not instead of an
    invoice, therefore I want the goods vatable returned as a negative
    number.
    Thanks in advance.
    Wez

    quote:
    ...the client wishes for me to use an MS Access db
    Too bad you didn't say that to begin with. I believe that
    with Access you might consider using IIF().
    Syntax:
    IIf(expr, truepart, falsepart)
    SELECT transactions.ourRef,
    transactions.transDate,
    IIf(transactions.transTypeID = 2,
    transactionDetails.goodsVatable * -1,
    transactionDetails.goodsVatable),
    transactionDetails.goodsNonVat,
    transactionDetails.VAT,
    transactionDetails.grandTotal,
    clients.clientCode,
    transTypes.transTypeDesc
    FROM transactions, transactionDetails, clients, transTypes
    WHERE transactions.transID = transactionDetails.transID
    AND transactions.clientID = clients.clientID
    AND transactions.transTypeID = transTypes.transTypeID
    Phil

Maybe you are looking for

  • I had to reinstall CS4 and now have error messages when opening bridge and photoshop

    The error message is "The specified module could not be found. C:\Program Files (x86)\Common Files\Adobe\Adobe Version Cue CS4\Client\4.0.1\Version Cue.DLL

  • ITunes songs

    I bought many songs in my history of itunes and would like to download everything I bought in the past (from itunes store) to my new computer. How do I go about doing this? Is there a catalog of my purchase history and where can I download all of the

  • Change only the Netmask of private interconnect 11g RAC 2

    Hi, I want to change only the netmask of private interface in 11.2.0.3 RAC. e.g. IPADDR=169.254.0.1 NETMASK=255.255.128.0 to IPADDR=169.254.0.1 NETMASK=255.255.0.0 Do I have to run any oifcfg commands? Regards, Zubair

  • Cisco 7604 System controller errors

    Hello Can any one help me with the followign errors message: I have a 7604 with the following IOS Cisco IOS Software, c7600s3223_rp Software (c7600s3223_rp-ADVIPSERVICESK9-M), Version 12.2(33)SRB5, RELEASE SOFTWARE (fc2) but for some days now I am re

  • Drill down functionality based on SAP BI queries

    Hi, I've a requirment to put Xcelcius on top of SAP BI. Lets say we have a BI report (report A) on comparison of products. We have another BI report (report B) which is having detailed data for any chosen product. The requirement is as follows- 1) We