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

Similar Messages

  • While downloading the latest IOS update to my iPhone 4, my phone went into a frozen state with the update 2/3's complete. It's remained like this for the past 12 hours. I can't turn the phone off, and I can't connect it to iTunes. Anyone know what to do?

    While downloading the latest IOS update to my iPhone 4S, my phone went into a frozen state with the update 2/3's complete. It's remained like this for the past 12 hours. I can't turn the phone off, and I can't connect it to iTunes. Anyone know what to do?

    If the place of purchase does not have a 'Lemon' policy (three replacements = refund or complete exchange), sadly you are out of luck.
    And Apple themselves do not have any power over what policy a reseller uses. You can call Apple Care and have them replace it, but the odds are you would probably get a standard replacement again like has previously happened. I'm pretty sure Apple holds their own sort of 'Lemon' polocy where if it's been replaced three times through them they'll swap it out for a brand new phone. Not 100% sure though, best bet is too call them again.
    And it ***** getting a response like that from their support personel, but hey, they can't all be that bad can they? I'm sure if you plead your case they'll try and help out. I've dealt with them in the past and had one or two people that rubbed me the wrong way, but most of them have been a great help and kept me a happy customer, haha.
    Regards,
    ThatGuy

  • How to write a case statement for the totals column of two different years (2013 and 2014) of the same month so that I can get a +/- column

    Please Help!!!
    How to write a case statement for the totals column of two different years (2013 and 2014) of the same month so that I can get a +/- column.
                                      January 2014         January
    2013                            +/-
                    Region   Entry   Exit  Total    Entry   Exit   Total   (Total of Jan2014-Total of Jan2013)
                    A               2         3      
    40        5       7        30                    40-30= 10

    What is a table structure? Sorry cannot test it right now..
    SELECT <columns>,(SELECT Total FROM tbl WHERE Y=2014)-(SELECT Total FROM tbl WHERE Y=2013)
    FROM tbl
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • CURSOR and CASE STATEMENT

    Hello All:
    Is it possible to have the CASE Statement in the cursor? If so, could you please show me how to use it? I tried to use it as following but it did not work on Form Builder. I tried it on Oracle SQL *Plus and it worked there.
    CURSOR tbl_chck_cur IS
    SELECT chck_id,
    NVL(sup_chck_id,'') sup_chck_id,
    (CASE WHEN sup_chck_id = null THEN
    (SELECT order_no from tbl_chck_lk where tbl_chck.chck_id = tbl_chck_lk.chck_id ) ELSE
    (SELECT order_no from tbl_chck_lk
    where tbl_chck.chck_id = tbl_chck_lk.chck_id ) END) order_no,
    FROM tbl_chck;
    Thanks in advance for any help.
    KT

    First, get rid of that NVL on sup_chck_id. It does nothing. What do you want it to do, anyway???
    And what is the second table "Tbl_chk_sub" in the from clause?
    Ignoring tbl_chk_sub, this might work:SELECT T1.chck_id,
           T1.sup_chck_id,
           Decode(T1.sup_chck_id, null,LK1.order_no,Lk2.order_no) order_no
      FROM tbl_chck T1,
           tbl_chck_lk LK1,
           tbl_chck_lk LK2
      where LK1.chck_id(+)     = T1.chck_id
        and LK2.sup_chck_id(+) = T1.sup_chck_idIf the above does not work, you will have to find a work-around -- either do the lookup select in the post-query trigger, or create a stored function you can call from the select that returns the correct order_no based on the two columns, sup_chck_id and chck_id.
    Do you know if we can use the SELECT statement inside the CASE statement?Sometimes Forms are several steps behind in adapting new sql features. So it looks like you cannot at this time.

  • Decode and Case

    Hi,
    What is the difference between decode and case?
    What are the cases in which we can use Decode and case
    Thanx

    you can not put Search CASE statements by using DECODE
    Eg:
    SELECT AVG(CASE WHEN e.salary > 2000 THEN e.salary ELSE 2000 END) "Average Salary" FROM employees e;Can't we?
    select avg(decode(sign(e.salary - 2000), 1, e.salary, 2000)) "Average Salary" from employees e;

  • Global succession updates are limited to 500 relationships. If more than 500 exist PLM presents a warning message and does not execute the update

    Global succession updates are limited to 500 relationships. If more than 500 exist PLM presents a warning message and does not execute the update.
    How/Where to increase the relationship count?
    The message which I can see :
    Warning:
    This specification has exceeded the number of parent relationships allowed by Where Used. The Where Used tool only supports up to 500 parent relationships.
    Thanks

    This really brings up a larger topic around change management.
    The questions you should start with is
    1. What kind of change is happening to the raw material? 
    2. Will this change affect anything upstream inside or outside of PLM4P? (Will this change affect nutrition, compliance, the ingredient statement, the label etc?)
    3. Who needs to approve this change?
    If they are non-material changes (changes that don't affect theoretical calculations, the ingredient statement, labeling, upstream systems that need to be notified etc) then you should be using get latest revision instead of global succession.   Get Latest Revision will automatically switch out the material with the latest approved version.  This logic is also configurable in case you need to add additional guard conditions.   We can also provide guidance around locking the get latest revision lock once a specification has reached the retired/obsolete state so changes won't occur for specifications in those statuses.
    If the changes to the raw material are material changes (changes that affect calculations, labeling etc) then the change should be reflected with a copy of the specification.  Dependent specifications then need to be re-issued so calculations can be performed and the appropriate workflow reviews can occur.   Smart Issue allows for filtering based on status and should let you re-issue in smaller blocks. 
    Let me know more about your change management strategy, how often large material changes happen and maybe example causes for those mass changes.  We can also schedule a change management training session for everyone where we can share our vision and tools available for change management.  This topic is quite large and generally requires a lot of business process discussion beyond just the tools available. 
    Thanks
    Kelly

  • Query Tuning - using CASE statement in the WHERE clause

    Hi All,
    My query has been modified to use a CASE statement in the WHERE clause to consider data from certain columns based on a parameter value. This modified query is doing a full table scan and running endlessly. Please suggest what may be done to improve its performance:
    Query:
    SELECT LAST_DAY(TRUNC(TO_TIMESTAMP(os.requestdatetime, 'yyyymmddhh24:mi:ss.ff4'))) AS summary_date,
    os.acctnum,
    os.avieworigin_refid,
    COUNT(1) cnt_articleview,
    SUM(NVL(autocompletedterm,0)) cnt_autocompletedterm
    FROM TABLE1 os
    WHERE os.acctnum IS NOT NULL
    AND os.avieworigin_refid IS NOT NULL
    AND os.requestdatetime IS NOT NULL
    AND UPPER(os.success_ind) = 'S'
    AND CASE WHEN
    Param_ValueToCheck  = 'FULL' AND get_date_timestamp(os.requestdatetime)  BETWEEN
    TO_DATE('01-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND
    TO_DATE('31-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
    THEN 1
    WHEN
    Param_ValueToCheck  = 'INCR' AND os.entry_createddate  BETWEEN
    TO_DATE('01-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND
    TO_DATE('31-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
    THEN 1
    END = 1
    AND CASE WHEN
    Param_ValueToCheck  = 'FULL' AND os.entry_CreatedDate BETWEEN
    TO_DATE('01-APR-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND
    TO_DATE('07-JUN-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
    THEN 1
    WHEN
    Param_ValueToCheck  = 'INCR' THEN 1
    END = 1
    GROUP BY LAST_DAY(TRUNC(TO_TIMESTAMP(os.requestdatetime, 'yyyymmddhh24:mi:ss.ff4'))), os.acctnum,os.avieworigin_refid;Table Description:
    (Number of rows : approx > 600,000,000)
    Name                           Null     Type      
    ARTICLEID                      NOT NULL NUMBER(20)
    USERKEY                                 NUMBER(10)
    AVIEWORIGIN_REFID                       VARCHAR2(10)
    SUCCESS_IND                             VARCHAR2(2)
    ENTRY_CREATEDDATE                       DATE      
    CREATED_BY                              VARCHAR2(10)
    FILENUMBER                              NUMBER(10)
    LINENUMBER                              NUMBER(10)
    ACCTNUM                                 VARCHAR2(10)
    AUTOCOMPLETEDTERM                       NUMBER(2) 
    REQUESTDATETIME                         VARCHAR2(19)Explain Plan
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 2224314832
    | Id  | Operation            | Name              | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
    |   0 | SELECT STATEMENT     |                   |   590 | 33040 |  2501K  (1)| 08:20:15 |       |       |
    |   1 |  HASH GROUP BY       |                   |   590 | 33040 |  2501K  (1)| 08:20:15 |       |       |
    |   2 |   PARTITION RANGE ALL|                   |   590 | 33040 |  2501K  (1)| 08:20:15 |     1 |1048575|
    |*  3 |    TABLE ACCESS FULL | TABLE1 |   590 | 33040 |  2501K  (1)| 08:20:15 |     1 |1048575|
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       3 - filter(UPPER("OS"."SUCCESS_IND")='S' AND CASE  WHEN ('FULL'='FULL' AND
                  "OS"."ENTRY_CREATEDDATE">=TO_DATE(' 2011-04-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
                  "OS"."ENTRY_CREATEDDATE"<=TO_DATE(' 2011-06-07 00:00:00', 'syyyy-mm-dd hh24:mi:ss')) THEN 1 WHEN
                  'FULL'='INCR' THEN 1 END =1 AND "OS"."REQUESTDATETIME" IS NOT NULL AND CASE  WHEN ('FULL'='FULL'
                  AND "ODS"."GET_DATE_TIMESTAMP"("REQUESTDATETIME")>=TO_DATE(' 2011-05-01 00:00:00', 'syyyy-mm-dd
                  hh24:mi:ss') AND "ODS"."GET_DATE_TIMESTAMP"("REQUESTDATETIME")<=TO_DATE(' 2011-05-31 00:00:00',
                  'syyyy-mm-dd hh24:mi:ss')) THEN 1 WHEN ('FULL'='INCR' AND "OS"."ENTRY_CREATEDDATE">=TO_DATE('
                  2011-05-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "OS"."ENTRY_CREATEDDATE"<=TO_DATE('
    PLAN_TABLE_OUTPUT
                  2011-05-31 00:00:00', 'syyyy-mm-dd hh24:mi:ss')) THEN 1 END =1 AND "OS"."ACCTNUM" IS NOT NULL AND
                  "OS"."AVIEWORIGIN_REFID" IS NOT NULL)Edited by: Chaitanya on Jun 9, 2011 2:44 AM
    Edited by: Chaitanya on Jun 9, 2011 2:47 AM

    Hi Dom,
    Modified Query:
    SELECT LAST_DAY(TRUNC(TO_TIMESTAMP(os.requestdatetime, 'yyyymmddhh24:mi:ss.ff4'))) AS summary_date,
    os.acctnum,
    os.avieworigin_refid,
    COUNT(1) cnt_articleview,
    SUM(NVL(autocompletedterm,0)) cnt_autocompletedterm
    FROM TABLE1 os
    WHERE os.acctnum IS NOT NULL
    AND os.avieworigin_refid IS NOT NULL
    AND os.requestdatetime IS NOT NULL
    AND UPPER(os.success_ind) = 'S'
    AND (('FULL'  = 'FULL'
    AND  (get_date_timestamp(os.requestdatetime)  BETWEEN TO_DATE('01-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
                   AND TO_DATE('31-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
    AND   os.entry_CreatedDate BETWEEN TO_DATE('01-APR-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
                   AND TO_DATE('07-JUN-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
    OR ('FULL'  = 'INCR'
    AND os.entry_createddate  BETWEEN TO_DATE('01-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
                   AND TO_DATE('31-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') ))
    GROUP BY LAST_DAY(TRUNC(TO_TIMESTAMP(os.requestdatetime, 'yyyymmddhh24:mi:ss.ff4'))), os.acctnum,os.avieworigin_refid;Execute Plan:
    PLAN_TABLE_OUTPUT
    Plan hash value: 3615447714
    | Id  | Operation                 | Name              | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     | Pstart| Pstop |
    |   0 | SELECT STATEMENT          |                   | 25125 |  1374K|       |   407K  (1)| 01:21:36 |       |       |
    |   1 |  HASH GROUP BY            |                   | 25125 |  1374K|  3768K|   407K  (1)| 01:21:36 |       |       |
    |   2 |   PARTITION RANGE ITERATOR|                   | 25125 |  1374K|       |   407K  (1)| 01:21:32 |    29 |    31 |
    |*  3 |    TABLE ACCESS FULL      | TABLE1 | 25125 |  1374K|       |   407K  (1)| 01:21:32 |    29 |    31 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       3 - filter("OS"."ENTRY_CREATEDDATE">=TO_DATE(' 2011-04-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
                  UPPER("OS"."SUCCESS_IND")='S' AND "OS"."REQUESTDATETIME" IS NOT NULL AND
                  "ODS"."GET_DATE_TIMESTAMP"("REQUESTDATETIME")>=TO_DATE(' 2011-05-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
                  "ODS"."GET_DATE_TIMESTAMP"("REQUESTDATETIME")<=TO_DATE(' 2011-05-31 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
                  "OS"."ACCTNUM" IS NOT NULL AND "OS"."AVIEWORIGIN_REFID" IS NOT NULL AND "OS"."ENTRY_CREATEDDATE"<=TO_DATE('
                  2011-06-07 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))Edited by: Chaitanya on Jun 9, 2011 4:51 AM

  • Issue with TableAdapter Configuration Wizard and CASE statements

    I am having an issue with using any CASE statements in the select clause for the Table Adapter Configuration Wizard (TCW).  I can take any query without a CASE and it will run fine, but inserting any CASE statement in the Select such as:
    SELECT
    (CASE WHEN :ras_sort = 'D' THEN TO_CHAR(a.TRANS_DATE,'YYYYMMDD')
      WHEN :ras_sort = 'C' THEN  c.CLAIMDEP_NAME
      WHEN :ras_sort = 'A' THEN  TO_CHAR(a.ACCOUNT_NUMBER)
      END) sort1
    FROM xxxx
    causes the TCW to error with "error in list of function arguments, 'THEN' not recognized" and several other errors.  I have tried with and without parameters in the CASE and have tried both forms of the CASE statement.  I have tried multiple queries, all that run with no problem outside of TCW and ODP, but this seems to be a real issue
    Is this a known problem and are there any workarounds that will allow use of the TCW?
    Thanks,
    Dave

    Hi Ashish,
    perhaps you launch the Web service wizard from the wrong location (i.e. not selecting the SEI you want to use). Did you strictly follow the steps described in the <a href="http://help.sap.com/saphelp_nwce10/helpdata/en/44/f36fa8fd1d41aae10000000a114a6b/frameset.htm">documentation</a> for creating the web service?

  • Diff b/w IF/ENDIF and CASE statement?

    Hi all,
    Plz let me know the difference between IF and CASE statements.Which one is better to be used in general...and are there any specific situations where we have to go for CASE insted of IF.
    Rgds,
    Reddy.

    Hi,
    Case statement is good for performance wise because here we declare cases
    and according to these cases program will be executed.
    When we use if statement then the cursur goes to in the loop, when ever
    the loop is not complete till then the programme will not execute.
    Thats by in performance basis the case statement is good.
    Let me try and explain using an example...
    1) For IF statement...
    Suppost you have a variable color..and you are checking it against color names.
    then your code will be
    IF COLOR == 'BLUE'.
        statements
    ELSEIF COLOR == 'BLACK'.
        statements.
    ...and so on....
    ENDIF.
    But if you use CASE Statement
    CASE COLOR.
    when 'BLUE'.
       statements.
    when 'BLACK'.
      statements.
    so follows that CASE is easy to use and performance wise is also better.
    Regards,
    Priyanka.

  • Diff between decode and case

    Hi
    I need small clarification about difference between decode and case
    Thanks who visit my thread

    And for those people who can't be ar$ed to follow links...
    Decode allows for conditional output where the conditions are straightforward matches between values.
    Case allows for regular conditions to be used such as greater than, less than etc.
    Some of the things done by case can be achieved through decode as well but in a more convoluted manner than simply using case.
    ;)

  • How does decode and case works?

    Hi,
    I want to know how decode and case works? How they process the arguements. Please explain me with some examples.
    Thanks,
    Sarav
    Edited by: 943941 on Jul 3, 2012 1:42 AM

    welcome
    check this link
    https://forums.oracle.com/forums/ann.jspa?annID=1535
    you will find everything you need
    DECODE compares expr to each search value one by one. If expr is equal to a search, then Oracle Database returns the corresponding result. If no match is found, then Oracle returns default. If default is omitted, then Oracle returns null.
    This example decodes the value warehouse_id. If warehouse_id is 1, then the function returns 'Southlake'; if warehouse_id is 2, then it returns 'San Francisco'; and so forth. If warehouse_id is not 1, 2, 3, or 4, then the function returns 'Non domestic'.
    SELECT product_id,
           DECODE (warehouse_id, 1, 'Southlake',
                                 2, 'San Francisco',
                                 3, 'New Jersey',
                                 4, 'Seattle',
                                    'Non domestic')
           "Location of inventory" FROM inventories
           WHERE product_id < 1775;Edited by: user 007 on Jul 3, 2012 2:40 PM

  • APEX_ITEM.MD5_CHECKSUM and Case Statements

    I have an updateable report
    select apex_item.display_and_save(3,parameter) ||
    APEX_ITEM.MD5_CHECKSUM(parameter,value_char,value_number,to_char(value_date,'dd.mm.yyyy'),param_set) ||
    apex_item.hidden(2,rownum) parameter
    ,value_char value_char_current
    ,APEX_ITEM.TEXT(4,value_char,20,128) value_char_new
    ,case when parameter in ('OBJINCID', 'HISTTRANSFERID') then '<span style="color:#000000;font-weight:bold">'||value_number||'</span>'
                else to_char(value_number) end  value_number_current
    ,APEX_ITEM.TEXT(5,value_number,10) value_number_new
    ,case when parameter = 'TRANSFERDAY' then '<span style="color:#000000;font-weight:bold">'||to_char(value_date,'dd.mm.yyyy')||'</span>'
                else to_char(value_date,'dd.mm.yyyy') end value_date_current
    ,APEX_ITEM.DATE_POPUP2(6,value_date,'DD.MM.YYYY','15','10','style=""',null,null,null,null,null,'both',null,'MONTH_AND_YEAR') value_date_new
    ,apex_item.display_and_save(7,param_set) param_set
    ,apex_item.display_and_save(8,param_type) param_type
    ,APEX_ITEM.TEXT(9,jobname) jobname
    ,system system
    ,config config
    ,APEX_ITEM.TEXT(10,parameter) parameter_hid
    ,APEX_ITEM.TEXT(11,value_number) vnhid
    ,APEX_ITEM.DATE_POPUP2(12,value_date,'DD.MM.YYYY','15','10','style=""',null,null,null,null,null,'both',null,'MONTH_AND_YEAR') vdhid
    from etl_job_param
    where config = substr(:P285_CONFIG,instr(:P285_CONFIG,'_')+1)
    and system = :P285_SYSTEMI would like to change my sql for the value_date_new col to
    ,case when parameter = 'TRANSFERDAY' then
    APEX_ITEM.DATE_POPUP2(6,NULL,'DD.MM.YYYY','15','10','style="" disabled="disabled"',null,null,null,null,null,'both',null,'MONTH_AND_YEAR')
    else
    APEX_ITEM.DATE_POPUP2(6,value_date,'DD.MM.YYYY','15','10','style=""',null,null,null,null,null,'both',null,'MONTH_AND_YEAR')  end value_date_newI think I need to change my checksum so if parameter = 'TRANSFERDAY' then use the value from the vdhid column and not value_date_new.
    It is not allowing me to use column alias in the checksum
    How do I do this ?
    Gus

    Well, you could either put the CASE statement in the checksum parameter as well (duplicating logic = bad) or use a factored subquery with the case statment in and alias that column, then reference it in the main query (logic in one place = good).
    Cheers
    Ben

  • I updated to iOS 7 and now some of my apps won't display in landscape mode and they did before the update. Any ideas on how to fix it?

    I updated to iOS 7 and now some of my apps won't display in landscape mode and they did before the update. Any ideas on how to fix it?

    This could be from having restrictions enabled. Icons completely disappear when "restricted"

  • When i try to do a software update, it finishes and then says that the update cannot be saved because it has probably been corrupted during the download. This has happened a number of times and i do not know why, any help?

    When i try to do a software update, it finishes and then says that the update cannot be saved because it has probably been corrupted during the download. This has happened a number of times and i do not know why, any help?

    asifmanzoor wrote:
    i have 10.7.2, this download is 10.7.5
    Are you Downloading it from here  >  http://support.apple.com/kb/dl1582
    asifmanzoor wrote:
    yes, i am using wifi
    1)  Turn your Wi-Fi router OFF... wait 30 seconds... Turn it back ON.
    OR...
    Do not use Wi-Fi and connect Directly to your Internet via ethernet cable.

  • I put a Tesco sim (02 carrier) in 2 unlocked phones, Both phones are now locked to 02, 02 blame apple, I connect the iphone to itunes and it states that the new carrier (orange) is not supported

    I put a Tesco sim (02 carrier) in 2 unlocked phones, Both phones are now locked to 02, 02 blame apple, I connect the iphone to itunes and it states that the new carrier (orange) is not supported, Isk this of both 02 and apple, who's phone is this and what right do you have to lock a previously unlocked phone?  very angry

    Where did you get these phones?
    These and other forums are full of people with iPhone unlocking problems - the net result is that, as others have said, is:
    If you bought them from Apple they will be (and stay) unlocked.
    If you bought them PAYG from CPW then they will lock to the first SIM activated.
    Any other contract or PAYG phone iPhone bought from the networks WILL be locked by them too.
    However, all is not lost. The original purchaser can request for the phones to be unlocked by Apple, via the carrier. The carriers usually charge around £20 to do this, or gratis if you're out of contract.
    You are the original purchaser, right? If not, you need to get in touch with that person and pray they'll help you out.

Maybe you are looking for

  • Intel iMac and H/K Soundsticks

    Everytime my intel iMac wakes from sleep, it doesn't recognize my soundsticks. They're available in the system preferences/sound output, but when I choose them they won't play. The only way to get them to play is to unplug the power to the soundstick

  • HT1153 can't connect my iPhone to my mac

    how do i get my mac to connect to my iphone 4 through bluetooth?

  • Text "dead zone" in tables

    Go to this page: http://thedecoartist.com/ARCHERwebsite/CAT_USinteriorDetails.html In Dreamweaver I cannot select any text in the far right two columns of the table with the text cursor. The only way I can either edit or enter text into those two col

  • Db2start in SAP

    hi, we have installed SAP ECC 6.0 on linux with DB2 9.1. Every thing was working fine but from the past two days we am unable to start SAP. I am getting the following error when we use startsap command Checking db6 db Database ABAP Database is not av

  • Safari is not logging history?

    Safari is not logging history on my iPad air