DECODE/CASE

Hi,
I tried DECODE in OWB 10G. It gave me error.
Is it a bug?
I tried the following case statement in OWB expression
1)CASE TO_CHAR(INGRP1.A1)
WHEN NULL THEN TO_CHAR(INGRP1.A2)
ELSE
TO_CHAR(INGRP1.A2) || ' . ' || TO_CHAR( INGRP1.A1 )
END
OWB validated ok. Even if A1 is NULL, it takes ELSE branch and put A2 ' . ' as result.
Any thoughts?
If I change as follows
2) CASE WHEN TO_CHAR(INGRP1.A1)
IS NULL THEN TO_CHAR(INGRP1.A2)
ELSE
TO_CHAR(INGRP1.A2) || ' . ' || TO_CHAR( INGRP1.A1 )
END
It worked ok.
What is happening here?
Thanks in advance.
RI

Hi,
comparing with NULL always results in false, even the condition NULL=NULL returns false.
If you want to check for NULL values, you have to use "WHERE a IS NULL".
So your statements work as designed.
Regards,
Carsten.

Similar Messages

  • What is the difference betwee decode & case function

    Hi
    What is the difference betwee decode & case function
    1.decode can't used in pl/sql 1) case can be user
    2.in decode we can't use (>,<,>=) 2) we can use
    any other do u have....
    thanks in advance....

    DECODE works with expressions which are scalar values.
    CASE can work with predicates and subqueries in searchable form.
    There is one more Important difference between CASE and DECODE
    DECODE can be used Only inside SQL statement....
    But CASE can be used any where even as a parameter of a function/procedure
    Eg:-
    SQL> create or replace procedure pro_01(n number) is
      2  begin
      3  dbms_output.put_line(' The number  = '||n);
      4  End;
      5  /
    Procedure created.
    SQL> set serverout on
    SQL> var a varchar2(5);
    SQL> Begin
      2  :a := 'ONE';
      3  End;
      4  /
    PL/SQL procedure successfully completed.
    SQL> Begin
      2   pro_01(Decode(:a,'ONE',1,0));
      3  End;
      4  /
    pro_01(Decode(:a,'ONE',1,0));
    ERROR at line 2:
    ORA-06550: line 2, column 9:
    PLS-00204: function or pseudo-column 'DECODE' may be used inside a SQL
    statement only
    ORA-06550: line 2, column 2:
    PL/SQL: Statement ignored
    SQL> Begin
      2    pro_01(case :a when 'ONE' then 1 else 0 end);
      3  End;
      4  /
    The number  = 1
    PL/SQL procedure successfully completed.Message was edited by:
    Avi
    Message was edited by:
    Avi

  • Decode/Case in Where clause

    Hello,
    We are experiencing an issue with a Select statement that uses Decode in the Where clause. Specifically, it seems to be ignoring a nested Decode and just returning the default value. We have another nested decode that works fine, though.
    A member of our team mentioned that he believed there was an issue with using Decode and Case statements inside of a where clause within HTML DB...Is this correct? If it is, is there a workaround? Since the nested Decode works elsewhere in this statement, that doesn't seem right.
    My select statement looks like:
    SELECT
       SUBSTR(OBOB.OBOB_CNAME, 0, 30) d,
       OBOB.OBOB_UID r
    FROM
       ISR_OBOB_OBJECT OBOB,
       ISR_OBAF_OBJECT_AFFILIATION OBAF,
       ISR.ISR_OBSD_SDR OBSD
    WHERE
       OBOB.OBOB_UID = OBSD.OBOB_UID AND
       OBOB.OBOB_UID = OBAF.OBOB_B_UID AND
    /*If Personal radio button is selected, displays all SDRs associated with user.
      If All is selected, displays all SDRs associated with IS group selected from drop down list
          or every SDR.
       OBAF.OBOB_A_UID = DECODE(:P1_DISPLAY_ALL,
                                       'Personal', :F101_APP_USER_UID,
    /*This is the decode statement that it seems to ignore. If ALL is selected, the query should see if a group has
        has been selected from a drop down list that appears when the ALL button is chosen. If a group is selected
        (the item isn't 0), only SDRs for that group should be shown. Otherwise, all SDRs for every group should display.
                                       'ALL', DECODE(:P1_SEARCH_IS_SUPPORT_GROUP, 0, OBAF.OBOB_A_UID, :P1_SEARCH_IS_SUPPORT_GROUP),
                                       OBAF.OBOB_A_UID) AND
    /*If Personal radio button is selected, display SDRs where user is the Primary assignee.
       OBAF.OBAT_UID = DECODE(:P1_DISPLAY_ALL, 'Personal', (select OBAT_UID from ISR_OBAT_OBJ_AFFIL_TYPE WHERE OBAT_APP_REF = 'SDR_PRIMARY'), OBAF.OBAT_UID) AND
    /*If a SDR Status (open, completed, on hold, not started...) is selected, only display the SDRs with that status.
       OBSD.KTTR_STATUS_UID = DECODE(:P1_ISR_STATUS_UID, 0, OBSD.KTTR_STATUS_UID, :P1_ISR_STATUS_UID) AND
    /*If SDR_History textbox is Null, or Open, Not Started, or On Hold SDR status has been selected, then all SDRs with
        a create date between today and 99999 months ago will display. Otherwise, only SDRs with a create date between
        today and however many months are in the textbox will display (i.e. Completed SDRs created in the past 6 months.)
       MONTHS_BETWEEN(sysdate, OBSD.OBSD_CREATE_DATE) <= DECODE(:P1_SDR_HISTORY, NULL, 99999, DECODE(:P1_ISR_STATUS_UID,
                                                              (select KTTR_UID from ISR_KTTR_TRANSLATION where KTTR_APP_REF = 'SD_STAT_OPEN'), 99999,
                                                              (select KTTR_UID from ISR_KTTR_TRANSLATION where KTTR_APP_REF = 'SD_STAT_NOT_STA'), 99999,
                                                              (select KTTR_UID from ISR_KTTR_TRANSLATION where KTTR_APP_REF = 'SD_STAT_HOLD'), 99999,
                                                              :P1_SDR_HISTORY))
    /*Alphabetical order
    Order by
       dWe originally wrote this as a PL/SQL statement that returned a query string since most of the where clause is dependent on items the user may or may not select, but we have moved the query into a multiselect list, which only seems to allow SQL Queries.
    Any help or advice would be appreciated.
    Thanks,
    Scott

    Scott: Did you try running that SQL statement in SQL Workshop in Apex? You can run it as it is, it will popup a window asking you to enter values for the bind variables.
    JAC73: I don't think an IN clause doesn't work that way, you need a actual SQL sub-query, not an expression from a DECODE/CASE statement. Search this site for str2tbl and see Tom's excellent discussion at
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:110612348061

  • Help with Decode/Case

    Hello All,
    Can I use decode/case function within a decode function?
    {code}
    SELECT TO_CHAR (
              EDMS_STRAGG_WC (
                 DISTINCT DECODE (
                             eqs.attrib_code,
                             'PRODUCT_AUTHORIZATION',    'Authorization: '
                                                      || CASE eqs.qual_value
                                                            WHEN 'LIST'
                                                            THEN
                                                               (SELECT lookup_desc
                                                                  FROM edmsadm.edms_lookup
                                                                 WHERE     lookup_type =
                                                                              'PARTNER_AUTHORIZATION'
                                                                       AND lookup_code =
                                                                              eqls.list_value)
                                                            ELSE
                                                               (SELECT lookup_desc
                                                                  FROM edmsadm.edms_lookup
                                                                 WHERE     lookup_type =
                                                                              'PARTNER_AUTHORIZATION'
                                                                       AND lookup_code =
                                                                              eqs.qual_value)
                                                         END,
                             'PRODUCT_CERTIFICATION',    'Certification: '
                                                      || CASE eqs.qual_value
                                                            WHEN 'LIST'
                                                            THEN
                                                               eqls.list_value
                                                            ELSE
                                                               eqs.qual_value
                                                         END,
                             'PRODUCT_SPECIALIZATION',    'Specialization: '
                                                       || (SELECT lookup_desc
                                                             FROM edmsadm.edms_lookup
                                                            WHERE     lookup_type =
                                                                         'PARTNER_SPECIALIZATION'
                                                                  AND lookup_code =
                                                                         CASE eqs.qual_value
                                                                            WHEN 'LIST'
                                                                            THEN
                                                                               eqls.list_value
                                                                            ELSE
                                                                               eqs.qual_value
                                                                         END))))
              program_value
      FROM edms_qual_stg eqs, edms_qual_list_stg eqls
    WHERE     1 = 1
           AND eqs.qual_id = eqls.qual_id(+)
           AND eqs.req_id = 192647
           AND eqs.disc_line_id = 598631
           AND eqs.attrib_code IN
                  ('PRODUCT_CERTIFICATION',
                   'PRODUCT_AUTHORIZATION',
                   'PRODUCT_SPECIALIZATION');
    {code}
    Edms_qual_stg:
    AND_OR_CONDITION
    ATTRIBUTE_SOURCE
    ATTRIB_CODE
    CREATED_BY
    CREATED_DT
    DISC_LINE_ID
    END_DT
    EXCLUDE_INCLUDE
    GROUP_AND_OR_CONDITION
    GROUP_CODE
    MAX_VALUE
    MIN_VALUE
    MODIFIED_BY
    MODIFIED_DT
    QUAL_APPL_PRECEDENCE
    QUAL_ID
    QUAL_OPERATOR
    QUAL_TYPE
    QUAL_VALUE
    REQ_ID
    START_DT
    Edms_qual_list_stg:
    ATTRIBUTE_SOURCE
    ATTRIB_CODE
    CREATED_BY
    CREATED_DT
    END_DT
    INCLUDE_AFFILIATES
    INCLUDE_EXCLUDE
    LIST_VALUE
    MODIFIED_BY
    MODIFIED_DT
    PRIMARY_PARTY
    QUAL_ID
    QUAL_LIST_ID
    REFERENCE_ID
    START_DT
    Edms_lookup:
    CREATED_BY
    CREATED_DT
    DISPLAY_SEQ
    EDMS_LOOKUP_ID
    END_DATE
    LOOKUP_CODE
    LOOKUP_DESC
    LOOKUP_REFERENCE
    LOOKUP_TYPE
    MODIFIED_BY
    MODIFIED_DT
    START_DATE
    SELECT eqs.qual_id, eqs.disc_line_id, eqs.req_id, eqs.attrib_code, eqs.qual_value, eqls.list_value
      FROM edms_qual_stg eqs, edms_qual_list_stg eqls
    WHERE     1 = 1
           AND eqs.qual_id = eqls.qual_id(+)
           AND disc_line_id = 598631
           AND req_id = 192647
           AND eqs.attrib_code IN
                  ('PRODUCT_CERTIFICATION',
                   'PRODUCT_AUTHORIZATION',
                   'PRODUCT_SPECIALIZATION');
    7509575    598631    192647    PRODUCT_CERTIFICATION    LIST    GOLD
    7509575    598631    192647    PRODUCT_CERTIFICATION    LIST    SILVER
    7509576    598631    192647    PRODUCT_AUTHORIZATION    LIST    ATP - JOULEX PROVIDER ESCO
    7509576    598631    192647    PRODUCT_AUTHORIZATION    LIST    ATP - JOULEX PROVIDER IDENTIFY
    7509577    598631    192647    PRODUCT_SPECIALIZATION    LIST    ADVANCED SECURITY
    7509577    598631    192647    PRODUCT_SPECIALIZATION    LIST    EXPRESS FOUNDATION
    Required Output:
    Certification: GOLD, SILVER, Authorization: ATP - JOULEX PROVIDER ESCO, ATP - JOULEX PROVIDER IDENTIFY,  SPECIALIZATION: ADVANCED SECURITY, EXPRESS FOUNDATION.
    Thx
    Shank.

    Hi,
    Sure; a DECODE or CASE expression that returns a NUMBER can be used any place a NUMBER is expected, including within another DECODE or CASE expression.  A DECODE or CASE expression that returns a DATE can be used any place a DATE is expected, including within another DECODE or CASE expression.  A DECODE or CASE expression that returns a VARCHAR2 can be used almost any place a VARCHAR2 is expected.  (There a  couple of special situations where a string literal is absolutely required.)
    There are not many situations where you really need to do that, though.  It's usually simpler and more efficient to use a single CASE expression; nesting is rarely needed.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Simplify the problem as much as possible, so that it contains only enough to show the part you don't already know how to do.
    If you really need a user-defined function to show the problem, then include a CREATE FUNCTION statement, and explain what the function does.  Again, simplify: if the function isn't what you don't understand, post a problem that doesn't use the function.
    Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • Using DECODE, CASE

    Hi All,
    The Transformation Guide of OWB mentions that DECODE, CASE can be used. But I am unable to find either of these functions in the Expression Builder. Can you please tell me wher should I search for these functions, or if you could tell me if there is any other way of implementing IF THEN ELSE logic.
    -Arnab

    Hello Arnab,
    Just type your CASE ... END expression directly in the expr. builder window.
    Always press the Validate button for syntax verification when you have changed your expression.
    Regards, Hans Henrik

  • Which is Faster among DECODE & CASE Statment.

    Can you please explain me the reason behind the fastest among DECODE & CASE statement?

    user13483989 wrote:
    Decode is have better performance.Because it is Oracle Inbuilt Function.So no neet to Specify Paraameters,It already contain Parameter.
    So Performance is good With decode.Please prove it with evidence, rather than just making supposed factual statements.
    From my tests, there's no clear difference one way or the other...
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    v_dummy      number;
      3    v_timestamp  timestamp;
      4    v_timestamp2 timestamp;
      5  begin
      6    v_timestamp := CURRENT_TIMESTAMP;
      7    dbms_output.put_line(v_timestamp);
      8    -- Test DECODE
      9    select count(*)
    10    into   v_dummy
    11    from   (select rownum rn from dual connect by rownum <= 1000000)
    12    where  decode(mod(rn,19),0,1,0) = 1;
    13    v_timestamp2 := CURRENT_TIMESTAMP;
    14    dbms_output.put_line(v_timestamp2);
    15    dbms_output.put_line('Decode Time Taken: '||(v_timestamp2 - v_timestamp) DAY TO SECOND);
    16    v_timestamp := CURRENT_TIMESTAMP;
    17    dbms_output.put_line(v_timestamp);
    18    -- Test CASE
    19    select count(*)
    20    into   v_dummy
    21    from   (select rownum rn from dual connect by rownum <= 1000000)
    22    where  case when mod(rn,19) = 0 then 1 else 0 end = 1;
    23    v_timestamp2 := CURRENT_TIMESTAMP;
    24    dbms_output.put_line(v_timestamp2);
    25    dbms_output.put_line('Case Time Taken:   '||(v_timestamp2 - v_timestamp) DAY TO SECOND);
    26* end;
    SQL> /
    18-JAN-11 12.01.58.856000
    18-JAN-11 12.02.00.653000
    Decode Time Taken: +000000000 00:00:01.797000000
    18-JAN-11 12.02.00.653000
    18-JAN-11 12.02.02.309000
    Case Time Taken:   +000000000 00:00:01.656000000
    PL/SQL procedure successfully completed.
    SQL> /
    18-JAN-11 12.02.03.668000
    18-JAN-11 12.02.05.403000
    Decode Time Taken: +000000000 00:00:01.735000000
    18-JAN-11 12.02.05.403000
    18-JAN-11 12.02.07.152000
    Case Time Taken:   +000000000 00:00:01.749000000
    PL/SQL procedure successfully completed.
    SQL> /
    18-JAN-11 12.02.07.871000
    18-JAN-11 12.02.09.777000
    Decode Time Taken: +000000000 00:00:01.906000000
    18-JAN-11 12.02.09.777000
    18-JAN-11 12.02.11.684000
    Case Time Taken:   +000000000 00:00:01.907000000
    PL/SQL procedure successfully completed.
    SQL> /
    18-JAN-11 12.02.15.324000
    18-JAN-11 12.02.17.090000
    Decode Time Taken: +000000000 00:00:01.766000000
    18-JAN-11 12.02.17.090000
    18-JAN-11 12.02.18.855000
    Case Time Taken:   +000000000 00:00:01.765000000
    PL/SQL procedure successfully completed.
    SQL>

  • Decode Case statement to insert total text

    Where the AGE BRACKET fields are empty or Null I need to insert "Total" text? Can anybody help?
    Table
    SOURCE CODE     AGE BRACKET     COUNT
    CLUBBEN     0-40 Years     3     
    CLUBBEN     41-49 Years     6     
    CLUBBEN     50-59 Years     38     
    CLUBBEN     60-69 Years     205     
    CLUBBEN     70-79 Years     181     
    CLUBBEN     80+ Years     19     
    CLUBBEN          452     
    CLUBJUNE     41-49 Years     2     
    CLUBJUNE     50-59 Years     21     
    CLUBJUNE     60-69 Years     100     
    CLUBJUNE     80+ Years     1     
    CLUBJUNE          124     
    TOTAL          576     
    Script Currently entered
    SELECT DECODE(GROUPING(F.SOURCE_CODE),1,'TOTAL',0,F.SOURCE_CODE) as "SOURCE CODE",
    CASE
    WHEN D.AGE BETWEEN '0' AND '40' THEN '0-40 Years'
    WHEN D.AGE BETWEEN '41' AND '49' THEN '41-49 Years'
    WHEN D.AGE BETWEEN '50' AND '59' THEN '50-59 Years'
    WHEN D.AGE BETWEEN '60' AND '69' THEN '60-69 Years'
    WHEN D.AGE BETWEEN '70' AND '79' THEN '70-79 Years'
    WHEN D.AGE >= '80' THEN '80+ Years'
    ELSE ''
    END AS"AGE BRACKET",
    COUNT(F.MEMBER_COUNT) "COUNT"
    FROM A3_FACT_NEW F, DIM_AGE D
    WHERE F.AGE_KEY = D.AGE
    AND F.JOIN_DATE BETWEEN '25/JUNE/2012' AND '30/AUGUST/2012'
    AND F.BEN_TYPE = 'Prime member'
    AND F.SOURCE_CODE IN ('CLUBBEN','CLUBJUNE')
    GROUP BY ROLLUP(F.SOURCE_CODE,
    CASE
    WHEN D.AGE BETWEEN '0' AND '40' THEN '0-40 Years'
    WHEN D.AGE BETWEEN '41' AND '49' THEN '41-49 Years'
    WHEN D.AGE BETWEEN '50' AND '59' THEN '50-59 Years'
    WHEN D.AGE BETWEEN '60' AND '69' THEN '60-69 Years'
    WHEN D.AGE BETWEEN '70' AND '79' THEN '70-79 Years'
    WHEN D.AGE >= '80' THEN '80+ Years'
    ELSE ''
    END)
    ORDER BY(F.SOURCE_CODE),(2)
    --------------------------------------------------------------------------------------------------------------

    Welcome to the forum!!
    Please consider the following when you post a question. This would help us help you better
    1. New features keep coming in every oracle version so please provide Your Oracle DB Version to get the best possible answer.
    You can use the following query and do a copy past of the output.
    select * from v$version 2. This forum has a very good Search Feature. Please use that before posting your question. Because for most of the questions
    that are asked the answer is already there.
    3. We dont know your DB structure or How your Data is. So you need to let us know. The best way would be to give some sample data like this.
    I have the following table called sales
    with sales
    as
          select 1 sales_id, 1 prod_id, 1001 inv_num, 120 qty from dual
          union all
          select 2 sales_id, 1 prod_id, 1002 inv_num, 25 qty from dual
    select *
      from sales 4. Rather than telling what you want in words its more easier when you give your expected output.
    For example in the above sales table, I want to know the total quantity and number of invoice for each product.
    The output should look like this
    Prod_id   sum_qty   count_inv
    1         145       2 5. When ever you get an error message post the entire error message. With the Error Number, The message and the Line number.
    6. Next thing is a very important thing to remember. Please post only well formatted code. Unformatted code is very hard to read.
    Your code format gets lost when you post it in the Oracle Forum. So in order to preserve it you need to
    use the {noformat}{noformat} tags.
    The usage of the tag is like this.
    <place your code here>\
    7. If you are posting a *Performance Related Question*. Please read
       {thread:id=501834} and {thread:id=863295}.
       Following those guide will be very helpful.
    8. Please keep in mind that this is a public forum. Here No question is URGENT.
       So use of words like *URGENT* or *ASAP* (As Soon As Possible) are considered to be rude.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Use of decode/case statements

    I am trying to use a decode or case statement to check for a particular field code of 'SIP' and if that is the value I only want half of the production figure used in the calculations for that field ('SIP').
    The following code works well without the items commented out:
    SELECT ALL
    FINDER_WIS.PRODUCTION_HDR.END_TIME as prod_date,
    'SCD' as district,
    --decode(FINDER_WIS.FACILITY_FIELD_X.FIELD_CODE,'SIP',FINDER_WIS.PRODUCTION_DATA.VOLUME/2,FINDER_WIS.PRODUCTION_DATA) AS TEST_SIP,
    /*case when FINDER_WIS.FACILITY_FIELD_X.FIELD_CODE = 'SIP'
         then FINDER_WIS.PRODUCTION_DATA.VOLUME/2
              else FINDER_WIS.PRODUCTION_DATA.VOLUME
    end as fieldtest,*/
    round(SUM(NVL(FINDER_WIS.PRODUCTION_DATA.VOLUME,0))) as total_oil,
    ROUND(SUM(NVL(FINDER_WIS.PRODUCTION_DATA.VOLUME,0)) / TO_NUMBER(TO_CHAR(FINDER_WIS.PRODUCTION_HDR.END_TIME,'DD'))) AS BOPD
    FROM FINDER_WIS.PRODUCTION_HDR,
    FINDER_WIS.PRODUCTION_DATA,
    FINDER_WIS.FACILITY,
    FINDER_WIS.REPORTING_GROUP,
    FINDER_WIS.REPORTING_GROUP_DETAIL,
    FINDER_WIS.FACILITY_FIELD_X,
    SELECT distinct FINDER_WIS.FACILITY.FACILITY_S
    FROM FINDER_WIS.PRODUCTION_HDR,
    FINDER_WIS.PRODUCTION_DATA,
    FINDER_WIS.FACILITY,
    FINDER_WIS.REPORTING_GROUP,
    FINDER_WIS.REPORTING_GROUP_DETAIL
    WHERE (FINDER_WIS.PRODUCTION_HDR.ACTIVITY_TYPE = 'ALLOCATED'
    AND FINDER_WIS.PRODUCTION_HDR.TIME_PERIOD_TYPE = 'MONTH'
    AND FINDER_WIS.PRODUCTION_HDR.STATE_TYPE = 'STANDARD'
    AND FINDER_WIS.PRODUCTION_HDR.EXISTENCE_TYPE = 'ACTUAL'
    AND FINDER_WIS.PRODUCTION_DATA.MATERIAL_TYPE='OIL'
    and FINDER_WIS.REPORTING_GROUP.REPORTING_GROUP_TYPE = 'ASSET_TEAM'
    AND FINDER_WIS.REPORTING_GROUP.REPORTING_GROUP_ID ='SCD'
    and finder_wis.production_HDR.SOURCE = 'NEWWIS'
    AND FINDER_WIS.PRODUCTION_HDR.START_TIME BETWEEN :startdate_var AND :enddate_var)
    AND ((FINDER_WIS.PRODUCTION_DATA.PRODUCTION_HDR_S=FINDER_WIS.PRODUCTION_HDR.PRODUCTION_HDR_S)
    and (FINDER_WIS.PRODUCTION_HDR.FACILITY_S = FINDER_WIS.FACILITY.FACILITY_S)
    and (FINDER_WIS.PRODUCTION_HDR.START_TIME between FINDER_WIS.REPORTING_GROUP_DETAIL.start_time and nvl(FINDER_WIS.REPORTING_GROUP_DETAIL.end_time,'01-JAN-2010')
    or FINDER_WIS.PRODUCTION_HDR.end_TIME between FINDER_WIS.REPORTING_GROUP_DETAIL.start_time and nvl(FINDER_WIS.REPORTING_GROUP_DETAIL.end_time,'01-JAN-2010'))
    AND (FINDER_WIS.REPORTING_GROUP.REPORTING_GROUP_S = FINDER_WIS.REPORTING_GROUP_DETAIL.REPORTING_GROUP_S)
    AND (FINDER_WIS.FACILITY.FACILITY_S = FINDER_WIS.REPORTING_GROUP_DETAIL.FACILITY_S)))T
    WHERE (FINDER_WIS.PRODUCTION_HDR.ACTIVITY_TYPE = 'ALLOCATED'
    AND FINDER_WIS.PRODUCTION_HDR.TIME_PERIOD_TYPE = 'MONTH'
    AND FINDER_WIS.PRODUCTION_HDR.STATE_TYPE = 'STANDARD'
    AND FINDER_WIS.PRODUCTION_HDR.EXISTENCE_TYPE = 'ACTUAL'
    AND FINDER_WIS.PRODUCTION_DATA.MATERIAL_TYPE='OIL'
    and FINDER_WIS.REPORTING_GROUP.REPORTING_GROUP_TYPE = 'ASSET_TEAM'
    and finder_wis.production_HDR.SOURCE = 'NEWWIS'
    AND FINDER_WIS.PRODUCTION_HDR.START_TIME BETWEEN :startdate_var AND :enddate_var)
    AND ((FINDER_WIS.FACILITY.FACILITY_S = T.FACILITY_S)
    AND (FINDER_WIS.PRODUCTION_DATA.PRODUCTION_HDR_S=FINDER_WIS.PRODUCTION_HDR.PRODUCTION_HDR_S)
    AND FINDER_WIS.FACILITY_FIELD_X.UWI = FINDER_WIS.FACILITY.UWI
    AND FINDER_WIS.FACILITY_FIELD_X.FIELD_CODE NOT IN ('MW','BRM','PLG','SIP')
    and (FINDER_WIS.PRODUCTION_HDR.FACILITY_S = FINDER_WIS.FACILITY.FACILITY_S)
    and (FINDER_WIS.PRODUCTION_HDR.START_TIME between FINDER_WIS.REPORTING_GROUP_DETAIL.start_time and nvl(FINDER_WIS.REPORTING_GROUP_DETAIL.end_time,'01-JAN-2010')
    or FINDER_WIS.PRODUCTION_HDR.end_TIME between FINDER_WIS.REPORTING_GROUP_DETAIL.start_time and nvl(FINDER_WIS.REPORTING_GROUP_DETAIL.end_time,'01-JAN-2010'))
    AND (FINDER_WIS.REPORTING_GROUP.REPORTING_GROUP_S = FINDER_WIS.REPORTING_GROUP_DETAIL.REPORTING_GROUP_S)
    AND (FINDER_WIS.FACILITY.FACILITY_S = FINDER_WIS.REPORTING_GROUP_DETAIL.FACILITY_S))
    GROUP BY FINDER_WIS.PRODUCTION_HDR.END_TIME
    the results look like this but this is without the values for the 'SIP' field:
    PROD_DATE     DISTRICT     TOTAL_OIL BOPD
    31/10/2007     SCD     168009     5420
    30/11/2007     SCD     167339     5578
    31/12/2007     SCD     170277     5493
    31/01/2008     SCD     173677     5602
    29/02/2008     SCD     168498     5810
    31/03/2008     SCD     172689     5571
    30/04/2008     SCD     168180     5606
    31/05/2008     SCD     165448     5337
    30/06/2008     SCD     164631     5488
    31/07/2008     SCD     170073     5486
    31/08/2008     SCD     166520     5372
    30/09/2008     SCD     160321     5344
    When I try to add the decode or case statement, I get ORA-00979; not a Group By expression as the error.
    Can anyone assist me with this please?
    Thanks in advance

    Hi and welcome to the forum.
    Simply put the field names you use in your DECODE also in your GROUP BY and it should work:
    simple example:
    MHO%xe> with t as (
      2  select 1 col1, 1 col2 from dual union all
      3  select 1 col1, 1 col2 from dual union all
      4  select 2 col1, 2 col2 from dual union all
      5  select 3 col1, 3 col2 from dual union all
      6  select 4 col1, 4 col2 from dual
      7  )
      8  select col1
      9  ,      decode(col1, 1, col2*100, col2)
    10  ,      sum(col2)
    11  from   t
    12  group by col1 -->> NO col2 here...
    13  order by col1;
    ,      decode(col1, 1, col2*100, col2)
    FOUT in regel 9:
    .ORA-00979: not a GROUP BY expression
    Verstreken: 00:00:05.78
    MHO%xe> with t as (
      2  select 1 col1, 1 col2 from dual union all
      3  select 1 col1, 1 col2 from dual union all
      4  select 2 col1, 2 col2 from dual union all
      5  select 3 col1, 3 col2 from dual union all
      6  select 4 col1, 4 col2 from dual
      7  )
      8  select col1
      9  ,      decode(col1, 1, col2*100, col2)
    10  ,      sum(col2)
    11  from   t
    12  group by col1, col2
    13  order by col1;
          COL1 DECODE(COL1,1,COL2*100,COL2)  SUM(COL2)
             1                          100          2
             2                            2          2
             3                            3          3
             4                            4          4

  • CASE vs DECODE - CASE with SUM and All in Page Item is non aggregable

    Hi,
    I'm using Discoverer 9.0.4.
    After switching calculations from DECODE to CASE
    I found out that case gives a non aggregable result when using a Page Item and selecting <All>.
    The calculations
    (SUM x) / (SUM y)
    or
    (x SUM) / (y SUM)
    where x and y are variables, work fine with page item <All>.
    But for example:
    CASE WHEN 1=2 THEN 1 ELSE (SUM x) / (SUM y) END
    gives non-aggregable.
    The same code works with DECODE:
    DECODE(1,2,1,(SUM x) / (SUM y))
    and is aggregable.
    Does anyone know a reason or a way to make it work with CASE?
    Thanks,
    Joao Noronha
    P.S.: I wanted <= comparisons and CASE is the best in simplicity,
    but now I know I can do it with DECODE, still looking ok using LEAST instead of ABS of the difference.

    Hi there
    I think therefore you have answered your own question and determined that using CASE in aggregations is not a good idea. I only threw out the two CASE options as ideas not as solutions, just in case (pardon the pun) one of these worked in your situation.
    Your comment I must say that if it worked it would give a wrong result (the sum of the divisions is not the same as the division of the sums) may give the wrong answer in your case but may be correct in others. It just depends how the items in the folder have been set up. I agree though that SUM(x) / SUM(y) will more often than not give the right answer.
    This discussion about DECODE vs CASE has been going on ever since Oracle introduced CASE as a means of placating a younger breed of user who needed an IF..THEN...ELSE construct and could not get their minds around the intricacies of DECODE. The DECODE is a much more reliable function than CASE because it has been around for a long time allowing Oracle plenty of opportunity to iron the bugs out of it. If I get a chance I will always use a DECODE whenever aggregations are required. However, when no aggregations are in use then I'll use CASE, simply because it's easier for users to work with.
    Unfortunately, users need to work with aggregations and so I don't see any alternative to Plus users having to learn DECODE. Whenever I teach Plus I always teach the users both CASE and DECODE but point out that DECODE has fewer issues that CASE. Oh, and talking of issues, try getting the THEN and ELSE components to return a different datatype. CASE has a fit and will not compile.
    Best wishes and glad you got your issue solved - you did right?
    Regards
    Michael

  • Problem using Decode/Case

    I have one table which stores candidates' response. The structure is like this
    (Seatno, Questionnumber, Answer).
    And I have another table Master as (Questionnumber, Answer)
    Now I want to calculate marks by comparing Candidate's response with Master.
    I tried to use decode and case. But was not successful.
    My query with decode was ...
    select c1.candidatesrno, sum(decode(c1.answer,(c1.answer=m1.answer),1,0))
    from candidate c1,master q1
    where c1.question=m1.question
    group by c1.candidatesrno
    And query with CASE was...
    select c1.candidatesrno,
    case when (c1.answer=m1.answer) then 1 else 0
    end resultset
    from candidate c1,master m1
    where c1.questionnumber=m1.questionnumber
    group by c1.candidatesrno
    Can anybody help ?

    I want to compare candidate's response with master
    table.
    Now for each question of Candidate, if its answer
    matches with answer in Master table I have to give 1
    marks...if it does not match I have to give 0
    marks...like this there are two-three conditions...
    Something like this ?
    test@ORA10G>
    test@ORA10G> with master as (
      2    select 'Q1' as question_num, 'A1' as answer_num from dual union all
      3    select 'Q2', 'A2' from dual union all
      4    select 'Q3', 'A3' from dual),
      5  candidate_response as (
      6    select 'S1' as seat_num, 'Q1' as question_num, 'A1' as answer_num from dual union all
      7    select 'S1', 'Q2', 'A2' from dual union all
      8    select 'S1', 'Q3', 'A3' from dual union all
      9    select 'S2', 'Q1', 'A5' from dual union all
    10    select 'S2', 'Q2', 'A6' from dual union all
    11    select 'S2', 'Q3', 'A3' from dual)
    12  --
    13  select
    14    cr.seat_num,
    15    cr.question_num,
    16    cr.answer_num,
    17    case when m.question_num is null and m.answer_num is null then '0 point'
    18         else '1 point'
    19    end as points
    20  from candidate_response cr, master m
    21  where cr.question_num = m.question_num(+)
    22  and cr.answer_num = m.answer_num(+)
    23  order by cr.seat_num, cr.question_num, cr.answer_num;
    SE QU AN POINTS
    S1 Q1 A1 1 point
    S1 Q2 A2 1 point
    S1 Q3 A3 1 point
    S2 Q1 A5 0 point
    S2 Q2 A6 0 point
    S2 Q3 A3 1 point
    6 rows selected.
    test@ORA10G>
    test@ORA10G> with master as (
      2    select 'Q1' as question_num, 'A1' as answer_num from dual union all
      3    select 'Q2', 'A2' from dual union all
      4    select 'Q3', 'A3' from dual),
      5  candidate_response as (
      6    select 'S1' as seat_num, 'Q1' as question_num, 'A1' as answer_num from dual union all
      7    select 'S1', 'Q2', 'A2' from dual union all
      8    select 'S1', 'Q3', 'A3' from dual union all
      9    select 'S2', 'Q1', 'A5' from dual union all
    10    select 'S2', 'Q2', 'A6' from dual union all
    11    select 'S2', 'Q3', 'A3' from dual)
    12  --
    13  select cr.seat_num, count(*) as score
    14  from candidate_response cr, master m
    15  where cr.question_num = m.question_num
    16  and cr.answer_num = m.answer_num
    17  group by cr.seat_num
    18  order by cr.seat_num;
    SE      SCORE
    S1          3
    S2          1
    test@ORA10G>
    test@ORA10G>pratz

  • How to use index, when query has decode/case

    Hi,
    I have the following query
    i have a index on party_id,party_type_Code in the zx_party_tax_profile table But this index is not used as Iam using a decode on the columns of the zx_party_tax_profile table,
    Is there any way i can rewrite the query so that it uses index
    sELECT /*+ INDEX(ZX_PARTY_TAX_PROFILE_U2) */ party_tax_profile_id FROM (SELECT
    ThirdPartyTaxProfileEO.SUPPLIER_FLAG,
    ThirdPartyTaxProfileEO.CUSTOMER_FLAG,
    ThirdPartyTaxProfileEO.SITE_FLAG,
    ThirdPartyTaxProfileEO.PARTY_TAX_PROFILE_ID,
    ThirdPartyTaxProfileEO.PARTY_ID,
    ThirdPartyTaxProfileEO.REP_REGISTRATION_NUMBER,
    ThirdPartyTaxProfileEO.OBJECT_VERSION_NUMBER,
    ThirdPartyTaxProfileEO.REGISTRATION_TYPE_CODE,
    ThirdPartyTaxProfileEO.COUNTRY_CODE,
    ThirdPartyTaxProfileEO.MERGED_TO_PTP_ID,
    ThirdPartyTaxProfileEO.MERGED_STATUS_CODE,
    ThirdPartyTaxProfileEO.PROGRAM_APP_NAME,
    ThirdPartyTaxProfileEO.PROGRAM_NAME,
    PartyPEO.PARTY_NAME,
    PartyPEO.PARTY_ID AS PARTY_ID1,
    PartyPEO.PARTY_NUMBER,
    decode(ThirdPartyTaxProfileEO.CUSTOMER_FLAG,
    'Y',decode(ThirdPartyTaxProfileEO.SUPPLIER_FLAG,
    'Y', 'SC',
    'C'),
    decode(ThirdPartyTaxProfileEO.SUPPLIER_FLAG,
    'Y', 'S',
    NULL)
    ) AS PARTY_USAGE,
    ThirdPartyTaxProfileEO.REP_REGISTRATION_NUMBER AS TAX_REG_NUMBER,
    LkupPartyUsage.MEANING AS PARTY_USAGE_DESC,
    PartyPEO.PARTY_NAME AS PARTY_FULL_NAME,
    PartyPEO.ADDRESS1||','||
    PartyPEO.ADDRESS2||','||
    PartyPEO.ADDRESS3||','||
    PartyPEO.CITY||','||
    PartyPEO.postal_code||','||
    PartyPEO.COUNTRY AS ADDRESS,
    PartyPEO.COUNTRY AS COUNTRY_CODE_TCA,
    TerritoryPEO.TERRITORY_SHORT_NAME AS COUNTRY_NAME,
    PartyPEO.JGZZ_FISCAL_CODE AS TAX_PAYER_ID,
    PartyPEO.DUNS_NUMBER_C AS DUNS_NUMBER,
    PartyPEO.Party_Number as Party_Num_Calc,
    null as REGISTRATION_TYPE_NAME,
    null as ROUNDING_LEVEL_NAME,
    null as ROUNDING_RULE_NAME,
    null as COUNTRY_NAME_PTP,
    'ZX_PARTY_TAX_PROFILE' as TAX_REPORTING_ENTITY_CODE
    FROM ZX_PARTY_TAX_PROFILE ThirdPartyTaxProfileEO,
    HZ_PARTIES PartyPEO,
    FND_LOOKUP_VALUES_VL LkupPartyUsage,
    FND_TERRITORIES_VL TerritoryPEO
    WHERE ThirdPartyTaxProfileEO.PARTY_ID = PartyPEO.PARTY_ID AND
    LkupPartyUsage.LOOKUP_CODE = decode(ThirdPartyTaxProfileEO.CUSTOMER_FLAG,
    'Y',decode(ThirdPartyTaxProfileEO.SUPPLIER_FLAG,
    'Y', 'SC',
    'C'),
    decode(ThirdPartyTaxProfileEO.SUPPLIER_FLAG,
    'Y', 'S',
    NULL)
    ) AND
    PartyPEO.COUNTRY = TerritoryPEO.Territory_Code (+) AND
    LkupPartyUsage.LOOKUP_TYPE = 'ZX_TP_PARTY_USAGE'
    ORDER BY UPPER(PARTY_FULL_NAME)) QRSLT WHERE UPPER(PARTY_NAME) IS NOT
    NULL
    Any help will be appreciated

    You can rewrite your where clause to not use decode or case statements e.g. this:
      AND LkupPartyUsage.LOOKUP_CODE = DECODE( ThirdPartyTaxProfileEO.CUSTOMER_FLAG
                                , 'Y', DECODE( ThirdPartyTaxProfileEO.SUPPLIER_FLAG, 'Y', 'SC', 'C' )
                                     , DECODE( ThirdPartyTaxProfileEO.SUPPLIER_FLAG, 'Y', 'S', NULL ) )
                                     )can be rewritten to this:
    and (
          ( ThirdPartyTaxProfileEO.CUSTOMER_FLAG = 'Y'  AND
              ((ThirdPartyTaxProfileEO.SUPPLIER_FLAG = 'Y' AND LkupPartyUsage.LOOKUP_CODE = 'SC') or
                ThirdPartyTaxProfileEO.SUPPLIER_FLAG != 'Y' AND LkupPartyUsage.LOOKUP_CODE = 'C')) or
          ( ThirdPartyTaxProfileEO.CUSTOMER_FLAG != 'Y'  AND
              ((ThirdPartyTaxProfileEO.SUPPLIER_FLAG = 'Y' AND LkupPartyUsage.LOOKUP_CODE = 'S') or
                ThirdPartyTaxProfileEO.SUPPLIER_FLAG != 'Y' AND LkupPartyUsage.LOOKUP_CODE is null))
        )It's not as sussinct, but it avoids the use of functions that could be preventing the optimiser from using an index.

  • HELP !  is it transpose, pivot, decode, case or connect by- haven't a clue!

    I'm almost embarrassed about asking this but my sql skills just haven't kept up since 8i !!
    I know i could write a procedure and put the data into a temp table , but i really should get with the program and learn some new functions !!
    using select wo_num, g_start,g_end from batch
    I have a row returned from a table like so
    WO_NUM G_START G_END
    1000000 100 105
    Using a select statement I would like to turn it into
    WO_NUM G
    1000000 100
    1000000 101
    1000000 102
    1000000 103
    1000000 104
    1000000 105

    Hi,
    You're asking about a counter table, that is, a result set (that you can use like a table) that has all possible values in a range: in this case, all the integers between g_start and g_end.
    In Oracle 9 (and up) you can generate such a counter table using CONNECT BY.
    The query below does what you want for all rows in table_x:
    WITH     cntr     AS
         SELECT     LEVEL - 1     AS n
         FROM     dual
         CONNECT BY     LEVEL <= 1 + (
                                         SELECT  MAX (g_end - g_start)
                                  FROM    table_x
    SELECT    x.wo_num
    ,       g_start + c.n     AS g
    FROM       table_x     x
    JOIN       cntr          c     ON  x.g_end >= x.g_start + c.n
    ORDER BY  x.wo_num
    ,            g;But you don't want to do this for every row in table_x: you want to do it for every row in the result set of your original query. (It doesn't matter if there's only one row or not.)
    So add your original query as another sub-query, and use that instead of table_x:
    WITH       original_results  AS
         SELECT     wo_num
         ,     g_start
         ,     g_end
         FROM     table_x
         WHERE     column_1     < column_2
    ,     cntr     AS
         SELECT     LEVEL - 1     AS n
         FROM     dual
         CONNECT BY     LEVEL <= 1 + (
                                         SELECT  MAX (g_end - g_start)
                                  FROM    original_results
    SELECT    x.wo_num
    ,       g_start + c.n     AS g
    FROM       original_results     x
    JOIN       cntr               c     ON  x.g_end >= x.g_start + c.n
    ORDER BY  x.wo_num
    ,            g;The original query in this example is pretty simple, but you can use any query, involving joins and sub-queries.

  • How to do range calculation with decode/case

    Trying (unsuccesfully) to this as a Discoverer calculation:
    CASE WHEN ( Activity Composite fact.Activity Date >= TO_DATE('03-Jul-2007') AND Activity Composite fact.Activity Date <= TO_DATE('10-OCT-2007') ) THEN SUM(Activity Composite fact.Activity Amount) ELSE 0 END
    I get "Unimplemented Feature." I need to create a calculation that sums the amount for records within a date range only.
    I can't use conditions because I'm comparing a specific date range in one year to a comparable range in the other.
    Am I hoping against hope or is there a way to do this?
    Thanks...

    Hi,
    Try moving the SUM( ) around the entire Case statement, like so:
    SUM(CASE WHEN ( Activity Composite fact.Activity Date >= TO_DATE('03-Jul-2007') AND Activity Composite fact.Activity Date <= TO_DATE('10-OCT-2007') ) THEN Activity Composite fact.Activity Amount ELSE 0 END)
    See if that works.
    Brent

  • Help with Decode/CASE function

    Can anyone provide some help or insight how can this be done.
    Senario:
    I have two parameters in my report.
    Paramerer_A and Parameter_B
    If I enter a value (XYZ) in Parameter_A and value (XYZ) in Parameter_B, I want the report to display ERROR and do not run.

    Hi
    It is not possible to have a use defined message come up based on the values of parameters but we can stop the workbook from executing.
    First of all, you will will need to make sure that both parameters are optional and then create your condition such that it will not run if both are populated, like this:
    (Item1 = :Parameter_A OR Item2 = :Parameter_B)
    AND NOT
    :Parameter_A IS NOT NULL AND :Parameter_B IS NOT NULL
    You can also put in a check parameter that controls whether A or B should be used, with a prompt like this: Use Parameter A or Parameter B? Enter A or B
    :Check_Parameter = 'A' AND Item1 = :Parameter_A
    OR
    :Check_Parameter = 'B' AND Item2 = :Parameter_B
    Best wishes
    Michael

  • Decode and case statement in the update..

    Its is more to it, but I want to check with you guys, the experts on this, this look busy to me, it should be a more simplify way of doing it, do you think will work
    The government decide to change the ethnic codes, and we have to come with certain rules to in our report, anyway, do you think this will work? again It is more to it I declare my variables, this is just one part of the precedure.
    BEGIN
          UTL_FILE.fclose_all;
          v_file_handle := UTL_FILE.fopen (v_out_path, v_out_file, 'a');
          UTL_FILE.put_line (v_file_handle,
                             CHR (10) || TO_CHAR (SYSDATE, 'DD-MON-YYYY HH:MI:SS')
          UTL_FILE.put_line (v_file_handle, 'Entering  spbpers_update');
          SELECT upd_spbpers_upd_cur IS
              spriden_pidm,
              szscapp_birth_state,
              szscapp_birth_city,
              DECODE(szscapp_hisp_or_latino_ind,Y,'2',N,'1'),
              DECODE(szscapp_hisp_or_latino_options,XCM,'2',CUB,'2',MEX,'2',PRI,'2',XSM,'2',ESP,'2',XOH,'2'),  
              DECODE(szscapp_amer_indn_alaska_opt,XAN,'1','1',XCW,'1',XCH,'1',XCK,'1',XNV,'1',XSX,'1'),         
              DECODE(szscapp_amer_indn_alaska_other,XON,'1') (,IND,'1',JPN,'1',KOR,'1',PAK,'1',PHL,'1',VNM,'1',XEA,'1',XIS,'1',XSA,'1'),  
              DECODE(szscapp_asian_options,IND,'1',JPN,'1',KOR,'1',PAK,'1',PHL,'1',VNM,'1',XEA,'1',XIS,'1',XSA,'1'),   ,          
              DECODE(szscapp_other_east_asia,(IND,'1',JPN,'1',KOR,'1',PAK,'1',PHL,'1',VNM,'1',XEA,'1',XIS,'1',XSA,'1'),            
              DECODE(szscapp_other_indian_subcont,XIS,'1'),    
              DECODE(szscapp_other_southeast_asia,XSA,'1'),   
              DECODE(szscapp_blk_or_afr_amer_opt,XAA,'1',XAF,'1',XCB,'1',XOA,'1'),     
              DECODE(szscapp_blk_or_afr_amer_other,XOA,'1'),   
              DECODE(szscapp_natve_hawaian_options,GUM,'1',XHI,'1',ASM,'1',XOP,'1'), 
              DECODE(szscapp_hawaiian_other,XOP,'1'),             
              DECODE(szscapp_white_options,XEU,'1',XME,'1',XOW,'1'),           
              DECODE(szscapp_white_other(XOW,'1')
         FROM
             saturn_midd.szscapp 
         WHERE
         spriden_id =  szscapp_id
         AND  spriden_ntyp_code = 'CAPL'
       IF upd_spbpers_upd_cur%ISOPEN
          THEN
             CLOSE upd_spbpers_upd_cur;
          END IF;
          OPEN upd_spbpers_upd_cur;
          LOOP
             FETCH upd_spbpers_upd_cur
              INTO v_pidm,v_birth_state,v_birth_city,v_latino_ind,v_latino_options,
                   v_indn_alaska_opt,v_indn_alaska_other,v_asian_options,
                   v_other_east_asia,v_other_indian_subcont,v_other_southeast_asia,
                   v_blk_or_afr_amer_opt,v_blk_or_afr_amer_other,v_natve_hawaian_options,           
                   v_hawaiian_other,v_white_options,v_white_other;
             EXIT WHEN upd_spbpers_upd_cur%NOTFOUND; 
             IF upd_spbpers_upd_cur%FOUND
               UPDATE  saturn.spbpers
                           set SPBPERS_ETHN_CODE  = CASE
                   WHEN v_latino_ind            IS NOT NULL THEN (spbpers_ethn_code = v_latino_ind,spbpers_activity_date = sysdate)     
                   WHEN v_latino_options        IS NOT NULL THEN (spbpers_ethn_code = v_latino_options,spbpers_activity_date = sysdate)
                   WHEN v_indn_alaska_opt       IS NOT NULL THEN (spbpers_ethn_code = v_indn_alaska_opt,spbpers_activity_date = sysdate)
                   WHEN v_indn_alaska_other     IS NOT NULL THEN (spbpers_ethn_code = v_indn_alaska_other,spbpers_activity_date = sysdate)
                   WHEN v_asian_options         IS NOT NULL THEN (spbpers_ethn_code = v_asian_options,spbpers_activity_date = sysdate)
                   WHEN v_other_east_asia       IS NOT NULL THEN (spbpers_ethn_code = v_other_east_asia,spbpers_activity_date = sysdate)             
                   WHEN v_other_indian_subcont  IS NOT NULL THEN (spbpers_ethn_code = v_other_indian_subcont,spbpers_activity_date = sysdate)
                   WHEN v_other_southeast_asia  IS NOT NULL THEN (spbpers_ethn_code = v_other_southeast_asia,spbpers_activity_date = sysdate)
                   WHEN v_blk_or_afr_amer_opt   IS NOT NULL THEN (spbpers_ethn_code = v_blk_or_afr_amer_opt,spbpers_activity_date = sysdate)
                   WHEN v_blk_or_afr_amer_other IS NOT NULL THEN (spbpers_ethn_code = v_blk_or_afr_amer_other,spbpers_activity_date = sysdate)
                   WHEN v_natve_hawaian_options IS NOT NULL THEN (spbpers_ethn_code = v_natve_hawaian_options,spbpers_activity_date = sysdate)
                   WHEN v_hawaiian_other        IS NOT NULL THEN (spbpers_ethn_code = v_hawaiian_other,spbpers_activity_date = sysdate)
                   WHEN v_white_options         IS NOT NULL THEN (spbpers_ethn_code = v_white_options,spbpers_activity_date = sysdate)
                   WHEN v_white_other           IS NOT NULL THEN (spbpers_ethn_code = v_white_other,spbpers_activity_date = sysdate)
                   WHEN v_birth_state           IS NOT NULL THEN (spbpers_stat_code_birth = v_birth_state,spbpers_activity_date = sysdate)
                   WHEN v_birth_city            IS NOT NULL THEN (spbpers_city_birth = v_birth_city,spbpers_activity_date = sysdate)
                   WHERE spbpers_pidm = v_pidm;
                  END
                     END IF;
          END LOOP;

    Did the procedure compile ?
    Doesn't look like a right Decode syntax.
    DECODE (col1,'VAL1','This','VAL2','That','ElseThis')
    means
    --Psuedocode
    IF col1 = 'VAL1' THEN 'This'
    IF col1 = 'VAL2' THEN 'That'
    ELSE 'ElseThis'You can use CASE statement Instead of DECODE
    CASE
    when      szscapp_amer_indn_alaska_other
         in ('XON','IND','JPN','KOR','PAK' ..... )  THEN '1'
    when      szscapp_hisp_or_latino_options
         in ('XCM','CUB','MEX','PRI','XSM','ESP','XOH' ...) THEN '2'
    END  SS

Maybe you are looking for

  • IOS 6.1.4 Screenshot file type?

    Hi, This is a question I've been struggling to find an answer to online.  Its based on some forensic work I'm doing with an iPhone 5 ( Model: A1429) I have some IMG_####.PNG files within the Camera Roll that I have no idea how they got onto the phone

  • HP Laserjet M1132 MFP is too slow over the network!

    Hi, My HP Laserjet M1132 MFP is too slow over the network! I have connect the printer to a windows XP 32bit SP3 using UBS port. The printer works fine on the local computer but when sharing it over the network it works too slow, for example with prin

  • QM Scenario for Automatic Data Transfer to Inspection Lot

    Hi Experts, I have explained one QM scenario below. And also mentioned queries that I have in this. Could you please help me out on the same? There are 2 SAP systems, A and B. Process works as follows: -Delivery is created at A with B as recipient. -

  • Transfer Customer Master records from one company code to another company.

    hi ,     working on a rollout project , needed to transfer Customer Master records from one company code to another company code. is there any sap standard BDC/T-code as in case of Vendor Master FK15,Fk16(T-CODE) . thanks in advance. rahul Edited by:

  • Operations Console 2012 Kaput (Win7)

    So for some reason the Operations Console no longer works on my workstation. Trying to launch it causes a crash in MMC: Log Name:      Application Source:        Application Error Date:          6/11/2012 3:21:23 PM Event ID:      1000 Task Category: