What is the difference in case stmt

Hi
I'm getting the same output with the following case statements
SQL> select (case when empno=7566 then 100 else empno end)
  2  from emp;
(CASEWHENEMPNO=7566THEN100ELSEEMPNOEND)
                                   7369
                                   7521
                                    100
                                   7654
                                   7698
SQL> select (case empno when 7566 then 100 else empno end)
  2  from emp;
(CASEEMPNOWHEN7566THEN100ELSEEMPNOEND)
                                  7369
                                  7521
                                   100
                                  7654
                                  7698Apart from this do we have any difference between the above 2 case statments
Thanks

There is no difference in your two case statements. They represent same logic and thats why you are getting same output.
There are two ways to use case statements as shown by as well.
"CASE deptno when 10 then....." is used when we want to match the exact value using equality operator. This is same as "CASE when deptno=10 then ...."
"CASE when deptno >10 then....." is used when the operator is other than the "=" equality operator like "> ,<, Like,Bewteen etc" .
I thing you have got the point.
Regards
Edited by: NKU on Nov 4, 2008 9:44 PM

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

  • What is the difference between the following cases... ?

    What is the symbol *%2 %3 %4 %5 %6 %7* used for?
    What is the difference between the following cases about the symbol *%2 %3 %4 %5 %6 %7* ?
    Case 1:
    "%NEW_JAVA_HOME%"\bin\java %COH_OPTS% -Xms1g -Xmx1g com.tangosol.net.DefaultCacheServer
    %2 %3 %4 %5 %6 %7Case 2:
    com.tangosol.examples.%EXAMPLE%.Driver contacts %EXAMPLES_DIR%\..\resource\contacts.csv
    %2 %3 %4 %5 %6 %7Thank you

    It just passes whatever else was on the command line to the "java" command. So if you have a Windows test.cmd file that looks like this:
    java %1 %2 %3 %4 %5 %6 %7Then you can pretty much use "test" anywhere you would use "java", because it passes through its command line parameters (or at least up to 7 of them).
    Peace,
    Cameron Purdy | Oracle Coherence

  • What is the difference b/t the macbook a1432 and a1181, i think i ordered the wrong case?

    what is the difference b/t the macbook a1432 and a1181, i think i ordered the wrong case?

    A1181 is any of the seventeen models of the white or black MacBooks with the removable battery.
    A1278 is the one model of the Aluminum Unibody
    A1342 are the two models of the White Unibody
    There's no model A1432.
    To see which model you have go to the Apple in the upper left corner and select About This Mac, then click on More Info (and then System Report if you’re running 10.7 Lion). When System Profiler comes up check the Model Identifier and post it back here.

  • What is the difference between variable and Define

    WHAT IS THE DIFFERENCE BETWEEN
    these different declarations when it is done using the keyword "variable" and "define"
    and both of these are done OUTSIDE "DECLARE"
    VARIABLE g_monthly_sal NUMBER
    DEFINE p_annual_sal =5000
    -- I understand that p_annual_sal will be taken as a CHAR.
    -- ALSO IF DEFINE variable acts as macro variable, SO is it necessary to give it some value whenever we define it.
    if not what value would be substituted for it?
    OR does that mean whenever we want to specify data type for a bind varible we should use VARIABLE and
    when we do not want to specify type we use DEFINE?
    THANK YOU
    Edited by: user6287828 on Feb 24, 2009 11:03 AM
    Edited by: user6287828 on Feb 24, 2009 11:04 AM

    Both are SQL*plus commands. In a real programming environment you will not use such constructs (except a few rare scripting cases).
    The difference is how the construct is later used. DEFINE is more like a copy&paste string. Whereever the name of this substitution variable is found it will be pasted into the sql*plus session.
    VARIABLE creates a real variable. You can change the value and if follwos the usual principles of variables (including binding).
    Example can be found the docs:
    from the docs
    Where and How to Use Substitution Variables
    You can use substitution variables anywhere in SQL and SQL*Plus commands, except as the first word entered. When SQL*Plus encounters an undefined substitution variable in a command, SQL*Plus prompts you for the value.
    You can enter any string at the prompt, even one containing blanks and punctuation. If the SQL command containing the reference should have quote marks around the variable and you do not include them there, the user must include the quotes when prompted.
    SQL*Plus reads your response from the keyboard, even if you have redirected terminal input or output to a file. If a terminal is not available (if, for example, you run the script in batch mode), SQL*Plus uses the redirected file.
    After you enter a value at the prompt, SQL*Plus lists the line containing the substitution variable twice: once before substituting the value you enter and once after substitution. You can suppress this listing by setting the SET command variable VERIFY to OFF.
    Using Bind Variables
    Bind variables are variables you create in SQL*Plus and then reference in PL/SQL or SQL. If you create a bind variable in SQL*Plus, you can use the variable as you would a declared variable in your PL/SQL subprogram and then access the variable from SQL*Plus. You can use bind variables for such things as storing return codes or debugging your PL/SQL subprograms.
    Because bind variables are recognized by SQL*Plus, you can display their values in SQL*Plus or reference them in PL/SQL subprograms that you run in SQL*Plus.
    Creating Bind Variables
    You create bind variables in SQL*Plus with the VARIABLE command. For example
    VARIABLE ret_val NUMBER
    This command creates a bind variable named ret_val with a datatype of NUMBER. See the VARIABLE command for more information. (To list all bind variables created in a session, type VARIABLE without any arguments.)
    Referencing Bind Variables
    You reference bind variables in PL/SQL by typing a colon (:) followed immediately by the name of the variable. For example
    :ret_val := 1;
    To change this bind variable in SQL*Plus, you must enter a PL/SQL block. For example:
    BEGIN
    :ret_val:=4;
    END;
    /

  • What is the difference between exists and in

    hi all
    if i have these queries
    1- select ename from emp where ename in ( select ename from emp where empno=10)
    and
    2- select ename from emp where exists ( select ename from emp where empno=10)
    what is the difference between exists and in is that only when i use in i have to bring the field name or what.... i mean in a complex SQL queries is it will give the same answer
    Thanks

    You get two entirely different result sets that may be the same. Haah! What do I mean by that.
    SQL> select table_name from user_tables;
    TABLE_NAME
    BAR
    FOO
    2 rows selected.
    SQL> select table_name from user_tables where table_name in (select table_name from user_tables where table_name = 'FOO');
    TABLE_NAME
    FOO
    1 row selected.
    SQL> select table_name from user_tables where exists(select table_name from user_tables where table_name = 'FOO');
    TABLE_NAME
    BAR
    FOO
    2 rows selected.So, why is this? the WHERE EXISTS means 'if the next is true', much like where 1=1 being always true and 1=2 being always false. In this case, where exists could be TRUE or FALSE, depending on the subquery.
    WHERE EXISTS can be useful for something like testing if we have data, without actually having to return columns.
    So, if you want to see if an employee exists you might say
    SELECT 1 FROM DUAL WHERE EXISTS( select * from emp where empid = 10);
    If there is a row in emp for empid=10, then you get back 1 from dual;
    This is what I call an 'optimistic' lookup because the WHERE EXISTS ends as soon as there is a hit. It does not care how many - only that at least one exists. It is optimistic because it will continue processing the table lookup until either it hits or reaches the end of the table - for a non-indexed query.

  • WHAT'S THE DIFFERENCE BETWEEN.....

    Hi friends,
    Please enlighten me ....
    What's the difference between using this.....
    1. Add User command functionality to ALVgrid report
    In order to add user command functionality to the ALV grid you need to perform the following steps:
                        1. Update 'REUSE_ALV_GRID_DISPLAY' FM call to include 'USER_COMMAND' FORM
                    2. Create 'USER_COMMAND' FORM
    call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
                i_callback_top_of_page   = 'TOP-OF-PAGE'
                I_callback_user_command = 'USER_COMMAND'   "see FORM
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
                i_save                  = 'X'
           tables
                t_outtab                = it_ekko
           exceptions
                program_error           = 1
                others                  = 2.
          FORM USER_COMMAND                                          *
          --> R_UCOMM                                                *
          --> RS_SELFIELD                                            *
    FORM user_command USING r_ucomm LIKE sy-ucomm
                      rs_selfield TYPE slis_selfield.
    Check function code
      CASE r_ucomm.
        WHEN '&IC1'.
      Check field clicked on within ALVgrid report
        IF rs_selfield-fieldname = 'EBELN'.
        Read data table, using index of row user clicked on
          READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
        Set parameter ID for transaction screen field
          SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
        Sxecute transaction ME23N, and skip initial data entry screen
          CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
        ENDIF.
      ENDCASE.
    ENDFORM.
    and using this----
    2. Add User command functionality to ALVgrid report
    In order modify PF_STATUS of ALV grid report you need to perform the following steps:
         1. Update 'REUSE_ALV_GRID_DISPLAY' FM call to include:
                        i_callback_pf_status_set = 'SET_PF_STATUS' statement.
         2. Create 'SET_PF_STATUS' FORM
         3. Create pf_status (i.e. 'ZNEWSTATUS').
              - It is recommend that you copy standard status'STANDARD' from function group SALV
                and modify it accordingly. ALV standard function codes always start with '&'.
    call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
                i_callback_top_of_page   = 'TOP-OF-PAGE'
                i_callback_pf_status_set = 'SET_PF_STATUS'   "see FORM
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
                i_save                  = 'X'
           tables
                t_outtab                = it_ekko
           exceptions
                program_error           = 1
                others                  = 2.
          FORM SET_PF_STATUS                                         *
    FORM set_pf_status USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS 'ZNEWSTATUS'.
                      "Copy of 'STANDARD' pf_status from fgroup SALV
    ENDFORM.
    I have assumed the former is used  when I am selecting a field on the list
    and the later when I have  created a pf-status. I mean to say... I have slected a field and click on some button to get further information.
    Please remove my confusion.
    Thanking you alll in advance,
    Hari Kiran.

    From their Terms & Conditions page:
    Grade A - Working phone in as new/mint condition. Complete with original box and accessories as sold new.
    Grade B (and Discounted) - Working phone in good condition with slight cosmetic blemishes. Charger supplied. If the phone includes a music player/radio then it is supplied with headphones. If the phone has PDA functionality a sync cable and/or docking cradle is supplied. Missing original packaging.
    Grade C (and Budget) - Working phone in poor cosmetic condition. Original or 3rd party charger supplied but missing accessories and original packaging.
    Substitute iPod for phone and I think it makes sense...
    tt2

  • What is the difference between credit memo in invoice year and in next year

    Hi!
    I'm new here.I'm study SAP ERP.I don't know what is the difference between credit memo in invoice year and credit memo in next year (asset accounting).Can you show and give me an example, please!
    Thanks and best regards!
    Edited by: dinhtuan on Jun 28, 2010 3:10 PM

    Hi,
    Maybe have a look at the SAP Help for further information (http://help.sap.com) : e.g. 'Posting Credit Memos Integrated with Vendor'  or 'Posting a Credit Memo Offset Against a Clearing Account' 
    Transaction type 105 for credit memo on current acquisition made in the current year, posting key 75. Or transaction type 160 for credit memo on acquisitions from prior years. posting key 75.
    Note: determine if the asset was acquired in the current fiscal year or in a closed fiscal year (Display asset values).
    If the asset was acquired in a fiscal year that is now closed, correct the past depreciation using a write-up (in that case check out and refer to Posting Write-Ups).
    I hope this helps.
    Kind regards,
    Brigitte

  • What is the difference between iterator.remove() ArrayList.remove()?

    Following code uses iterator.remove() ArrayList.remove().
    public class CollectionRemove
        private static void checkIteratorRemove()
             List<String> list = new ArrayList<String>();     
              list.add("1");
              list.add("2");
              list.add("3");     
             System.out.println("in checkWithIterator*************");
            Iterator<String> iter = list.iterator();
            while (iter.hasNext()) {
                String str = iter.next();           
                if (str.equals("2")) {
                    iter.remove();
                System.out.println("list Size: " + list.size() + " Element: " +  str);
        private static void checkListRemove()
             List<String> list = new ArrayList<String>();     
              list.add("1");
              list.add("2");
              list.add("3");     
            System.out.println("in ncheckWithForLoop*************");
            Iterator<String> iter = list.iterator();
            while (iter.hasNext()) 
                 String str = (String) iter.next();    
                if (str.equals("2")) {
                    list.remove(str);
                System.out.println("list Size: " + list.size() + " Element: " +  str);
        public static void main(String args[])
             checkIteratorRemove();
             checkListRemove();
    output is :
    in checkWithIterator*************
    list Size: 3 Element: 1
    list Size: 2 Element: 2
    list Size: 2 Element: 3
    in ncheckWithForLoop*************
    list Size: 3 Element: 1
    list Size: 2 Element: 2Why is this difference ? what is the difference between iterator.remove() ArrayList.remove()?

    In the case of Fail-fast iterator, if a thread modifies a collection directly while iterating over it, the iterator will thow ConcurrentModificationException . Say,
    for (Iterator it = collection.iterator(); it.hasNext()) {
        Object object = it.next();
        if (isConditionTrue) {
            // collection.remove(object);  can throw ConcurrentModificationException
            it.remove(object);
    }As per specs,
    Note that this exception does not always indicate that an object has been concurrently modified by a different thread. If a single thread issues a sequence of method invocations that violates the contract of an object, the object may throw this exception. For example, if a thread modifies a collection directly while it is iterating over the collection with a fail-fast iterator, the iterator will thow this exception.

  • What is the difference between upgradation and migration.

    Hi Guru's
    what is the difference between upgradation and migration.
    actuallly i involved in upgradation project, here my role is
    1. first i check the query's in 3.5 save the query and transport the query. and check the query in bex analyzer also.
    2. go to BI .7  find the query;s ,give the query name and save the query ,
    3. once save the query, again will come to 3.5 open the query , it will not open. this is my job here,
        come to 7.0 check the query in analyzer also.
    i am having littile bit confusion, how it will comes query in 7.0, why are u saving the query's in 3.5 and 7.0
    query's already available in 7.0 why are u doing this work?
    can i know the upgrades those  objects, is it neccessary, if necessary how can i upgrade.
    infoobje , transferrules, transferstructure ,infosoure, datasoure,updaterules, ods, cubes.
    Points will be Assingned ,
    Thanks & Regards
    prabhavathi

    Hi,
    I was talking in a general sense not on a query level.
    If your taling about migration in that level meaning as a part of larger upgradation (in your case 3.x to 7) there may be many places where you need to do this kind of activities.
    Fr eg migration into new data flow, Migration of Web templates from BW 3.x to Netweaver 2004s, etc
    Hope this helps.
    Thanks,
    JituK

  • What is the difference between Constant Window, Variable Window,Main Window

    hello all
    what is the difference between 1) Constant Window
                                                2) Variable Window
                                                3) Main Window   in SAP SCRIPT

    Hi,
    Window Types
    When defining a form window, you must select a window type for the window.
    You can choose between three types:
    Constant Windows (CONST)
    Variable Windows (VAR)
    Main Windows (MAIN)
    Constant Windows (CONST)
    Starting with Release 4.0, the system internally processes windows of type CONST similar to windows of type VAR.
    Therefore, if you create a new window, always use type VAR.
    Variable Windows (VAR) 
    The contents of variable windows is processed again for each page, on which the window appears.
    The system outputs only as much text as fits into the window. Text exceeding the window size is truncated;
    the system does not trigger a page break. Unlike constant windows, the page windows declared as variable windows may have different sizes on different form pages.
    As far as the processing of the window contents is concerned, the system currently treats constant and variable windows alike.
    The only difference is that constant windows have the same size throughout the form.
    Main Windows (MAIN) 
    Each form must have one window of type MAIN. Such a window is called the main window of the form.
    For SAPscript forms, the main window has a central meaning:
    It controls the page break.
    It contains the text body that may cover several pages.
    It allows to fix text elements at the upper and lower margins of the allocated page window (for example, for column headings).
    As soon as a window of type MAIN is full, SAPscript automatically triggers a page break and continues to
    output the remaining text in the main window of the subsequent page. Page windows of type MAIN have the same width throughout the form.
    The SAPscript composer thus avoids reformatting of the text after each page break.
    If a page does not have a main window, the system implicitly processes all other windows of the page and continues with the subsequent page.
    This page must not call itself as subsequent page (recursive call), since this would produce an endless loop.
    In such a case, SAPscript terminates the output after three subsequent pages.
    For printing header lines or totals, the different output areas of the main window are of special importance.
    go through this links:
    In Scripts Variable window and constant wind difference?
    Main Window
    Re: Main Window in SAP Script
    What is the difference between Constant window and variable window?
    Regards
    Adil

  • What is the difference between SCM, R/3 and BIW servers?

    Hi all,
    What is the difference R/3 and SCM and BIW.
    I have clear idea on R/3 and BIW .
    R/3 system used for short term data.
    BIW used for Historical data and process of planning.
    I do not know about SCM.
    In which cases will we use SCM?
    Thanks in Advance,
    Bhaskar
    Edited by: Wilian Segatto on Jan 14, 2010 7:39 PM

    Dear Bhaskar,
    Administrator Workbench is inbuilt in SAP SCM.
    SAP Advanced Planning and Optimization (SAP APO) offers a fully integrated pallet of functions that you use to plan and execute your supply chain processes. SAP APO supports the following:
    ·        Business collaboration on a strategic, tactical, and operational planning level
    ·        Co-operation between partners at all stages of the supply chain process; from order receipt, stock monitoring, through final shipping of the product
    ·        Cultivation of customer and business partner relationships
    ·        Constant optimization and evaluation of the supply chain network’s efficiency
    ICH offers collaboration between customers and suppliers.
    Regards,
    Naveen.

  • What is the difference between Business System and Business Service?

    Hi
    Please tell me what is the difference between Business System and Business Service...? In real time at what situation we will use Business System and in what situations we will use Business Service..? Please help me
    Best Regards
    Ravi Shankar B

    HI,
    Business system:
    If you want to address a particular business system as the sender or receiver of messages, choose this service type.
    A business system is an actual application system in a system landscape. A business system (service) comprises information about the inbound and outbound interfaces and the software component versions of the business system.
    You usually use business system services when configuring internal company processes.
    Business Service:
    If you want to address an abstract business entity as the sender or receiver of messages, choose this service type.
    Using a business service, you can define the technical or business subunits of the companies involved and then assign them the relevant interfaces.
    You usually use business services when configuring cross-company processes. In this case, you only make your interfaces known to the business partners involved and either do not make any details about your own system landscape available, or only specific details. 
    For example, you can define RosettaNet Partner Interface Processes (PIPs) as business services.
    Regards,
    Sudheer.

  • What is the difference between mc947ll and MD301LL

    What is the difference between these 2 part numbers for the iPad2 Leather case
    MD301LL appears to be offered on Apple store while MC947LL is a 3rd party offering
    but I dont see a difference in specs but the MC947LL is offered for a lower price
    Rob

    HSRP Versus VRRP Comparison Table
    HSRP
    VRRP
    Propietary
    Standards based
    RFC 2281
    RFC 3768
    Separate IP Address needed for the Virtual
    Can use the physical IP Address of the Virtual, if needed, saving IP space.
    One Master, One Standby, all others are listening
    One Master, all other routers are backup
    More familiar to most network engineers
    Less familiar - yet very similar
    Can track an interface for failover
    Can track an interface for failover (depending on operating system and version, it can also track the reachability of an IP address)
    All HSRP routers use multicast hello packets to 224.0.0.2 (all routers) for version 1 or 224.0.0.102 for version 2.
    All VRRP routers use IP protcol number 112 (vrrp) to communicate via multicast IP address 224.0.0.18
    All virtual router must use MAC address 0000.0c07.acXX where XX is the group ID.
    All virtual routers must use 00-00-5E-00-01-XX as its Media Access Control (MAC) address

  • What is the difference between Service and Component

    What is the difference between Service and Component?

    Generally, the implementation of a service will be comprised of many components, each of which will be comprised of many objects.
    Services should correspond to cohesive collections of use cases (eg an online bank), components are at a finer granularity (eg a table of numbers).
    Pete

Maybe you are looking for

  • Filter groups for outbound Vendor master , customer master idocs

    I need to create Vendor , Customer IDOCS CREMAS and DEBMAS only when the user changes the company code . I do not want the IDOCS to be produced when any other fields change. I am able to achieve the same using filter groups for Cost Center but not fo

  • JFileChooser or FileDialog??? Dilema!!

    hi there, I tried implementin a "Save As" Option using JFileChooser.. It works fine.. But wen i dont specify an extension.. it does not take the default extension specified using filters. Ex.. Say i try to Save "test" and the file type below reads ".

  • Photoshop/Illustrator Crashing

    I have just recently upgraded my Illustrator to CS6 but have had Photoshop CS6 for a while now. Whenever I use them together by dragging files from ai to Photoshop my photoshop crashes any time I attempt to save the PSD. In ai. when I take a portion

  • Cs2 on mini mac won't load starting today -- been working for years

    cs2 on mini mac won't load starting today -- been working for years

  • Selection in BexGetCellValue

    If in rows I got some KFG that is used as Selection (with some characteristic restrictions). So, my question is how should I point this selsction in formula if IT DOESN"T HAVE ANY TECH NAME?