Replace CASE with DECODE

Guys,
I want to replace CASE statement with DECODE. How ?
case when msg.is_swap = 'Y' and msg.buy_sell = 1 then 'SO'
when msg.is_swap = 'Y' and msg.buy_sell = 0 then 'SI'
else ''
end As TransactionType
How should i implement DECODE function to do the above one ?
Regards
Karthik

Karthik_ORACLE wrote:
Thanks for all your replies.
As i am new to ORACLE, one of my friend told me that DECODE will be faster than CASE. is it true ? Thats why i wanted to convertNeed to be proved ! See the following thread :
Re: what is better and fast to use between decode and case
Oracle version dependant, plateform dependant, and still the difference is near to 0.
Nicolas.

Similar Messages

  • Error while replacing IF statements with DECODE function in procedure

    Hi All,
    I have created a procedure which has nested IF statements. Now I want to replace the IF statements with DECODE functions to improve performance.
    Procedure:
    IF (var_int_sev = '0')
    THEN
    var_sev := '2';
    ELSE
    SELECT sev
    INTO var_int_sev
    FROM errorconfig
    WHERE errorcode = var_errorcode;
    var_sev := var_int_sev;
    END IF;
    I converted the above IF statement into DECODE function as mentioned below:
    var_Sev := DECODE(var_int_sev,0,2,SELECT severity FROM errorconfig WHERE errorcode=var_ErrorCode)
    But it throws below error at the select statement used inside DECODE.
    Error(58,51): PLS-00103: Encountered the symbol "SELECT" when expecting one of the following: ( - + case mod new not null others <an identifier> <a double-quoted delimited-identifier> <a bind variable> avg count current exists max min prior sql stddev sum variance execute forall merge time timestamp interval date <a string literal with character set specification> <a number> <a single-quoted SQL string> pipe <an alternatively-quoted string literal with character set specification> <an alternativ
    Can someone help me in converting the IF to DECODE in the above case. Also how can we use a select statement inside decode.

    instead of trying to rewrite all your code and hoping that the performance will be better, it's a better option to investigate and find out which part of your application is slow
    read this:
    When your query takes too long ...

  • 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

  • Replace slippery dm1-1040 case with a soft touch surface case

    I just purchased a dm1-4010us laptop last month only to find that its just announced replacement (dm1-4210) has a soft touch non-slippery case.  Can I replace the original plastic and slippery case with the newer one?  What is the part number, price, and availability of the new case?
    Alternatively, is there some rubberized adhesive tape or skin cover that could be added to the current laptop to make it less likely to slip out of my hands?  I just don't want to drop this thing!
    Thanks,
    DED

    Hi,
    Do you mean a cover or a whole chassis replacement??
    http://www.amazon.co.uk/DURAGADGET-Reversible-Neop​rene-Pavilion-IdeaPad/dp/B006K15LZC/ref=sr_1_14?ie​...
    Dv6-7000 /Full HD/Core i5-3360M/GF 650M/Corsair 8GB/Intel 7260AC/Samsung Pro 256GB
    Testing - HP 15-p000
    HP Touchpad provided by HP
    Currently on Debian Wheeze
    *Please, help other users with the same issue by marking your solved topics as "Accept as Solution"*

  • What is the Optional(other than Case or Decode)

    Hi friends,
    i need to refer an image to the corresponding blob content in my report for each and every row. i tried with case or decode but it is helpless as the case and decode does not support BLOB format, instead what is the other optional i can use inorder to solve the problem
    SELECT
      decode(attachment,(select attachment from it_issues where lower(name) like '%txt%') ,
           '<img src="#WORKSPACE_IMAGES#Notepad.jpg">',
           (select attachment from it_issues where lower(name) like '%pdf%'),
           '<img src="#WORKSPACE_IMAGES#Adobe pdf.bmp">',
            (select attachment from it_issues where  lower(name) like '%xls%'),
           '<img src="#WORKSPACE_IMAGES#Excel.png">',
            (select attachment from it_issues where  lower(name) like '%html%'),
           '<img src="#WORKSPACE_IMAGES#Html.bmp">',
            (select attachment from it_issues where  lower(name) like '%sql%'),
           '<img src="#WORKSPACE_IMAGES#Notepad.jpg">',
            (select attachment from it_issues where  lower(name) like '%ppt%'),
           '<img src="#WORKSPACE_IMAGES#powerpoint.jpg">',
            (select attachment from it_issues where  lower(name) like '%zip%'),
           '<img src="#WORKSPACE_IMAGES#rar 02.bmp">',
            (select attachment from it_issues where  lower(name) like '%doc%'),
           '<img src="#WORKSPACE_IMAGES#word.bmp">', null) Attachment
      FROM   it_issuesAbove is My code which is not sufficient to use, any replacement to it.. It will be very helpful for me
    Regards,
    Mini

    Hi metzguar,
    Thanks for the reply my image is stored in the attachment column but that image name is stored in filename column in my table, so i cannot refer attachment = txt, because the image name(txt)is stored in another column filename.
    But i need to show the image icon in my attachment column where the image is storing. That is the problem for me.
    Thanks
    Regards,
    Mini

  • My Macbook Pro was stolen, and I have replaced it with a Macbook Air. New hard drive is too small for a Time Machine restore. How do I restore my more-expensive apps (ie iWorks) on my new Macbook without repurchasing them?

    My Macbook Pro was recently stolen, and I have replaced it with a Macbook Air. I attempted to simply do a restore from the Macbook Pro's Time Machine backup, but since the new Macbook Air's hard drive is significantly smaller, a Time Machine restore was not possible. I even tried to choose only settings or only my User Profile (option) when restoring, but the backup was still too large to do a restore onto the new machine. How do I restore my more-expensive apps (ie iWorks) onto my new Macbook without repurchasing them? Also, I reaad somewhere that if you went to the Mac App Store and attempted to repurchase the app and clicked BUY, it would simply alert you that you have already purchased the app (and trigger a re-download)... NOT THE CASE... So I just dropped another $19.99 for a second copy of Pages... Not my intention....
    Any help would be greatly appreciated.
    LM

    you should get a usb backup drive as well.  time machine has limited use in my eyes. it saves things. but older things can be errased ad space drops without telling you
    nothing beats data redundancy.  2 saves is. 1.    and 1 is none
    im personally not fond of time machne though i use it only for a recovery parameter for a mac
    id never ever myself consider time machine a genuine data backup tool.  though most do consider it as such
    drive clones such as superduper and carbon copy cloner can clone your entire drive for emergency recovery.  and you can boot from them as well o. another mac

  • I have an iphone 5 that was originally with verizon but has been unlocked now by them and the phone is still under the apple warranty, if I go to replace for power button malfunctioning, will they give replace it with an unlocked phone as well?

    I currently have an iphone 5 that was verizon locked but has been unlocked by them because of my contract, the phone is still under the apple warranty but the power button is not working, if it was the case that apple has to replace it with another phone, will they replace with an unlocked phone now?
    thanks

    The SIM Lock is stored on the Apple Activation Server - if it has been correctly unlocked by a network then this would have been done on the Activation Server.
    When you get your replacement handset through Apple they mirror the activation server details of your existing handset and the current SIM LOCK status is mirror'd onto the new device.
    (100% Accurate - done mine 2 weeks before christmas due to original 5 sleep button stopped working)

  • Replace Null With 0 in Pivot Table in a BI Publisher Report (Not OBIEE Answ

    I have a problem with nulls in a pivot table. I got a measure column in my BI Answers analysis and I made a report with a model based in this analysis. When I add a pivot table to my report the 0 measures don't display.
    In first place I found that there's a bug (13054445). I download and ran the patch, then I tried editing data format in my analysis column and in BI Answers and this worked. The 0 displays correctly, but in the report it's still not displaying.
    I tried editing the formula in the analysis with:
    IFNULL(column,0)
    CASE WHEN column IS NULL THEN 0 ELSE column END
    CASE WHEN column IS NOT NULL THEN column ELSE 0 END
    IFNULL(cast("column"as varchar (10)), '0')
    And nothing works
    When I tried this: CASE WHEN column IS NULL THEN 0 ELSE 656565656 END
    in the report the 6565656565 display correctly but the 0 still doesn't display.
    Does anybody know if that is a bug? Or does another option exist that can I try?

    Hi,
    Following on with this post, I followed the document posted and the formula worked fine. I was able to replace nulls with strikethrough in a pivot table. Since combining the report into a compound layout, the strikethrough has reverted back to nulls. Even when just viewing the pivot table, the same applies.
    I have double checked the column properties and the condition(is null) and formatting(strikethrough) still exists but does not take effect in the pivot table.
    I hav also checked that no data exists in the fact table under the null categories and they are true.
    Can anyone help with this problem, I have also removed the condition and re-applied but still face the same problem.
    Thanks

  • Replacement order with vendor

    Hi experts
    I have a question on if SAP supports an replacement order with vendor.
    The scenario is the client could do a return PO with their vendor and then create another replacement order just to exchange the physical goods, there is no cost incurred for the replacement.
    The thing is if we handle such scenario with one return PO + new PO, there would definitely by financial impact as in invoice creation, LIV, etc.
    Therefore, would like to see if there is any SAP best practice / standard functions that we can make use of.
    Thanks and BR
    Dom

    hi,
    Could anyone please tell me why PO with vendor unknown is needed ?
    > Its mostly required when you wanna raise the procurement in any urgency or if the person entering the PO donot have a right to directly send the PO to the vendor or in case the vendor is required to be decided when the PO is being made...
    And what is the difference between PR and PO with vendor unknown ( If vendor is unknown , to whom should we send the PO then ) ?
    > When you save such PO, it is indirectly saved as PR only(internally), so there is no such difference physically....It not send to any of the vendor untill the PO is entered with the required vendor and send and saved as PO...
    What is the process cycle if we use a PO with vendor unknown . I know the process cycle with Vendor known .
    When you make such PO the system will ask you while saving with the tab " Save as PR" or PO with no vendor defined.....you need to click on it and save the PO as PR...
    Regards
    Priyanka.P

  • Satellite C850 - boot from DVD issue - want to replace Win8 with Win7U

    Got a new C850-1JZ yesterday and am trying to replace pre-installed Win 8 with Windows 7. I did create the recovery media (3 DVDs).
    The laptop is driving me "insane" as it seems to block any attempt to boot anything else other than Win8 on the preinstalled hdd.
    1.) Inserted Win 7 Ultimate DVD and tried to boot, would not boot from disk.
    2.) Loaded advanced boot menu and tried to boot from ODD, would not boot from disk it. (Options are LAN, USB, HDD, and ODD (assuming this is optical disk drive)
    3.) Changed regular bios settings boot priority to boot from ODD first, then HDD, would not boot from disk.
    4.) Learned there is a "security boot protection" mechanism enabled by default in the bios. Turned it off. Machine starts loading from ODD and says "Windows is loading files" then hangs. This is a MS original Win7 Ultimate disk from the Microsoft store, no scratches. Makes no sense. We actually have 2 of them, so I tried the other, same result.
    5.) Thought screw that, let's just put the hard drive from the other computer (T61) in here then and do clean new setup another time. Replaced hdd with other sata hdd that has Win 7 ultimate installed and system configured. When booting from hdd, it says "No OS" found and reboots. When booting from ODD, it starts with windows is loading files again and then freezes.
    What kind of other extra protection/virus blocker/stupid setting am I missing here? This is puzzling me. Thanks.

    *Thanks as***, that solves the problem.*
    After 10 days Toshiba Support in Germany came back with the same answer.
    Basically it seems the UEFI Firmware has some reference to Win 8 or the original OS and key and boat loader that is checks, and you cannot load anything else until you disable it by:
    1) In the BIOS, disable "secure boot" mode
    2) In the BIOS advanced settings, switch from UEFI to CMS mode.
    Then you should be able to install anything as the new OS.
    Also, if you want to write down your product key / serial number , since it is not printed anywhere (e.g. no sticker on the bottom of the laptop) [Belarc Advisor - Free Personal PC Audit|http://belarc.com/free_download.html] is a good tool to retrieve this from the registry and write it down.
    As far as I know it's "glued" to this particular hardware, so not portable, but it might be a good idea to write it down in case you lose the system recovery disk but would want to re-install it with the original serial number.

  • Replace words with images, in a table, using the search/replace tool

    Hello everybody
    I have a question:
    Is it possible to replace words with images, in a table, using the search/replace tool?
    My case:
    I have a table with about 9000 articles on about 400 pages. In this table there are words which I like to replace with Logos.
    Example: The word "DM" should be the Logo "DM" (.eps). This word is about 1200 times in this table.
    Is it possible to replace it automatically?
    Thank you very much for your helb.
    Kind regards Alex

    Hello Mr. Werner
    Thank you for your reply.
    Can I ask you which Version of InDesign do you use?
    I use CS 5.5 and there I can't find the change field "other" you told me.
    Can you see it on the screenshot? (Sorry it is german...)
    Thank you very much for your support.
    Kind regards Alex

  • How to use case and decode to extract the data

    Hello PL/SQL Gurus,
    I am using Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production version
    I have a table in following format -
    drop table TT2;
    create table TT2(College, Class,gender,status,fees) as select
    'IITB','MBA','M','P',255600 from dual union all select
    'IITK','MTech','M','P',300000 from dual union all select
    'IITD','MBA','F','P',450000 from dual union all select
    'IITKH','MBA','F','P',350000 from dual union all select
    'IITC','MTech','F','P',420000 from dual union all select
    'IITB','MTech','M','P',185000 from dual union all select
    'IITC','MTech','M','P',235000 from dual union all select
    'IITD','MBA','F','F',175000 from dual union all select
    'IITM','MBA','M','F',257000 from dual union all select     
    'IITKH','MTech','F','P',335000 from dual union all select
    'IITD','MBA','F','P',540335 from dual union all select
    'IITC','MBA','F','F',125089 from dual union all select
    'IITD','MTech','M','P',290756 from dual union all select
    'IITM','MBA','M','P',200000 from dual union all select     
    'IITKH','MBA','F','F',534990 from dual union all select
    'IITD','MBA','F','P',221000 from dual ;some of the extraction conditions are as following -
    CASE CONDITION
    College in 'IITB' and status='P'- 'WestRegion Passed'
    College in 'IITC' and status='P'- 'SouthRegion Passed'
    College in 'IITD' and 'IITK' and status='P' and Gender='F' - 'NothRegion Female Passed'
    College not in 'IITK' and status='F' - 'Ex Kanpur Failed'
    Expected output -
    Region Statnding     Fees
    WestRegion Passed     440460
    SouthRegion Passed     655000
    NothRegion Female Passed     1386335
    Ex Kanpur Failed     1092079SQL Used
    I am using the following query which only make sure of case but this is not how i want the output , if i try to use the case within decode then how to work on this -
    SELECT (CASE WHEN College in ('IITB') and status='P' then sum(fees) else 0 end) WP,
    (case when College in ('IITC') and status='P' then sum(fees) else 0 end) SP,
    (case when College in ('IITD','IITK') and gender='F' and status='P' then sum(fees) else 0 end) NFP,
    (case when College in ('IITK') and status='F' then sum(fees) else 0 end) ExKF
    FROM
    TT2
    GROUP BY College, Class,gender,status

    user555994 wrote:
    Thank you so much jeneesh i am really thankful to you ...vov.
    one more query in case if any of the selection don't have the output data , then values will be displayed like -One way..
    with t as
    --"Add all your descriptions
    (select 'WestRegion Passed' region_standing from dual union all
    select 'SouthRegion Passed' region_standing from dual union all
    select 'NothRegion Female Passed' region_standing from dual union all
    select 'Ex Kanpur Failed' region_standing from dual)
    select region_standing,sum(fees) fees
            from (
            (SELECT CASE WHEN College in ('IITB') and status='P'
                                then 'WestRegion Passed'
                        when College in ('IITC') and status='P'
                                then 'SouthRegion Passed'  
                        when College in ('IITD','IITK') and gender='F' and status='P'
                                then 'NothRegion Female Passed'
                        when College in ('IITK') and status='F'
                                then 'Ex Kanpur Failed'
                        else 'Others' end region_standing,
                        sum(fees) fees
            FROM TT2
            GROUP BY  CASE WHEN College in ('IITB') and status='P'
                                then 'WestRegion Passed'
                        when College in ('IITC') and status='P'
                                then 'SouthRegion Passed'  
                        when College in ('IITD','IITK') and gender='F' and status='P'
                                then 'NothRegion Female Passed'
                        when College in ('IITK') and status='F'
                                then 'Ex Kanpur Failed'
                        else 'Others' end
            union all
            select region_standing,0
            from t
    group by   region_standing;
    REGION_STANDING              FEES
    Others                     2567835
    NothRegion Female Passed   1211335
    WestRegion Passed           440600
    Ex Kanpur Failed                 0
    SouthRegion Passed          655000
    {code}
    Edited by: jeneesh on Nov 5, 2012 5:07 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Replacing Drive with a 500 gig 5400 RMP Drive

    I have a 2008 macbook pro with a 200 gig drive. I would like to replace it with a 500 gig 5400 RMP drive.
    Q: Does anyone have any favorites that:
    1 - fit inside correctly (some models are the wrong size)
    2 -DOES NOT have any of the recent drive firmware issues like:
    http://discussions.apple.com/thread.jspa?messageID=9815826&#9815826
    choices : Hitachi - Western digital - toshiba - samsung - seagate(? problems)

    revDAVE:
    As far as I can tell the clicking issue is intermittent. If you get one that clicks, you can it exchanged under warranty.
    The heat issue in 7200 rpm drives is a question people ask before they install a 7200 rpm HDD. (Incidentally, this question was raised about 5400 rpm drives when going from 4200 rpm drives.) I am not aware of any evidence that the 7200 rpm HDD is significantly hotter than 5400 rpm drives, and, as you may know, the perception of heat is often relative to the user. In any case, I would not worry about a heat issue with a 7200 rpm HDD.
    As to which brand to buy, that is a tough call. Be sure that you buy a drive that does not have GForce that will interfere with the MBP's SMS system. Hitachi is usually a safe bet. Seagate makes excellent drives, but some people have complained about issues with the 500 GB HDD. Remember that whatever brand you buy there is a possibility that your drive may be defective. In the final analysis it's your decision.
    cornelius

  • Is there any way to replace iPod4 with iPod5?

    Before two months I purchased iPod4. Is there any chance of replacing it with iPod5?
    If it is a case, then how much do I need to pay extra?

    Sell it; buy new one. There are no trade-ins at Apple.

  • Best Cooling Tower Case With Handles

    I'm trying to build a computer that will run Premiere Pro CS 5.5 and other programs.
    From reading on these forums, it looks like the best options for me right now are:
    i7 2600K
    Asus Sabertooth P67
    GTX 570
    16GB Patriot 1333MHz RAM
    Windows 7 Home
    500GB hard drive for the system and programs and page file
    Four 1TB drives in two RAID-0 configuations
    I'm probably not going to overclock right now because I don't want to be so concerned with overheating.  I may try overclocking later.
    I got some prices at Fry's, which includes the Corsair 600T Tower Case.
    I have 2 questions:
    1. I read on a forum that a guy was having problems with cooling on the 600T and another person said the 20mm fans are too small, that 30mm are better.
    2. I'm also trying to find a case that has a handle (or handles) so that I can transport it easily back and forth to another location.
    I've read here to stay away from the small or mini towers because they don't cool well enough and that makes sense to me.
    I only saw one at Fry's that had a handle, but I can't remember the name of it.
    I like the Mac Pro tower style handles.  Good and solid.
    Anyone know of a case that is:
    1. Great for cooling the above configuration, and
    2. Has a handle?
    Any feedback on the other componenets would be great as well.
    Thanks for any help or advice.

    Flyingfish,
    I can think of two pretty good possibilities for a luggable (mid or larger) case with a handle, and I'm sure there are others out there as well (Google LAN party):
    Thermaltake V5 Black Edition Mid-tower Gaming Case (has nice full handle)
    Any mid or full tower case + Sunbeam LAN Party Bag (includes strong straps that go around case to carry any case and keyboard using backpack style straps, shoulder strap, or a handle)
    Don't scrimp on cooling, even if you do not plan on overclocking; look for a dual fan heat pipe style that will fit with whatever case you do choose. Good cooling will keep your rendering reliable and will allow for the 2600k to "turbo" (speed itself up) more effectively.
    Now, regarding your component list, it looks just great! Don't forget a 850 watt p/s from a solid manufacturer. Also, skip the Corsair 600T; I brought one home I liked the design so well, then returned it when I realized the fans were not up there with the best fans and the typical high-quality replacement fans (Scythe Gentle Typhoon, etc.) do not fit without starting to drill holes, etc.
    Jim

Maybe you are looking for

  • Copy oracle server data to remote system over internet

    Hi, I am using Redhat 4 linux system as Oracle 10g server. My database is in archivelog mode. I am not good at data guard so i am not using it. But i want to copy my archive log file to another linux system over internet. so that in case of server cr

  • Problem with NOKIA 5800 Music Express

    Hi all, My NOKIA 5800 hasnt been working properly for some time. I can not make a call using my phone book (only if i dial the number i can call) though incoming call can be received. Apart from that, when i try to navigate tomy memory card, i cant a

  • Data model design in SAP BI

    Hi All, I have one requirement to design the data model for BI.  How to design a dataflow in BI. I know dataflow is different from data model. Could you pls let me know hoe to design it. Is there any model available ...so that i can refer. if not let

  • "Send to back" sending too far back?

    Why does the "send to back" command send stuff all the way behind the scenes? Why not just to the furthest position for the objects in your presentation?

  • Index.html file locks up Dreamweaver, TextEdit and Word

    I've been doing design work (print & web) on the Mac for 20+ years and this problem has me stumped: Yesterday I went to open my tried and true index.html file and it locked up Dreamweaver every time. I re-started the computer, ran Disk Utilities, del