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

Similar Messages

  • 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

  • Help with a CASE statement

    Please help me with a CASE Statement:
    - When ID = 15, 16, 17, 18 then "Bad"
    - when ID = 19, then "Average"
    - when ID = 21, then "Good"
    - else "Null"
    Thank you!!

    Well the 1st thing to do would be to correct my poor spelling... change    Delault : to Default :
    Don't know why you would get an error stating "The result of selection formula must be a boolean". It's working fine on my machine.
    If your ID field is numbers stored text you have a couple different options...
    1) Convert the ID to a number...
    Select  ToNumber({home.noone_ID})
    2) Wrap the ID values in double quotes...
       Case "15", "16", "17", "18" :
          "BAD"
    Even if this were your problem... the error should be something other than the boolean thing...
    Jason

  • Need help with upper case

    I'm stuck on my coding when I have to write a function to
    detect upper cases has been used in a sentence
    For example if my array element has this:
    2345
    SAINT PAUL
    STREET
    APT 5
    PHILADELPHIA
    I need to be able to write a code to let me know that the 2nd
    OR 3rd OR 5th element is written in upper case letter
    Or if I set the variable not as array, 2345 SAINT PAUL STREET
    APT 5 PHILADELPHIA
    I need to be able to detect that at least one of the section
    on that street name is written with upper case
    Can anyone help please?

    compare() cf function performs a case-sensitive comparison of
    2 strings
    and returns 0 is the strings are the same. so you can compare
    an
    uppercase version of the string to the original string, and
    if the
    comparison returns 0 then your string is in uppercase:
    <cfif compare(ucase(myarray[2]), myarray[2]) is 0>
    <!--- the string in myarray[2] IS in uppercase --->
    <cfelse>
    <!--- it is NOT in uppercase --->
    </cfif>
    the above code compares the value of the second array element
    converted
    to uppercase to the original value of the second array
    element. if the
    result is 0, i.e. the uppercase and original strings are the
    same, then
    you know the original string is in uppercase.
    if you are dealing with a single string (which is equivalent
    to a
    space-delimited list), then use appropriate list function to
    get
    required list element, i.e. listfirst(), listlast(),
    listgetat()...
    <cfif compare(ucase(listlast(mylist, " ")),
    listlast(mylist, " ")) is 0>
    <!--- the last element in the list IS in uppercase --->
    <cfelse>
    <!--- it is NOT in uppercase --->
    </cfif>
    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/

  • Help with multiple case statements

    Hello,
    I am new to BO.  I am on XI 3.0.  SQL 2005.  In Designer, I am trying to create a measure in a financial universe that would end up being multiple case statements within one select.  This is what I tried to do, but it doesn't work with the two case statements.  Can I use an ELSE leading into the second CASE WHEN somehow?  How can I accomplish this?  Sorry for my ignorance!
    CASE WHEN dbo.ClientBudgetYear.DateStage1Approved > 01/01/1900 AND dbo.ClientBudgetMonth.Month = 12 THEN dbo.ClientBudgetMonth.Stage1Sales END
    CASE WHEN  dbo.ClientBudgetYear.DateStage1Approved > 01/01/1900 AND dbo.ClientBudgetMonth.Month = 11 THEN dbo.ClientBudgetMonth.Stage1Sales END
    Any Suggestions?
    Thanks,
    Holly

    Holly,
    I don't know enough about your data or requirement to provide a solution, however, the construct that you post will not work because it causes you to build an object with multiple case statements when only one case statement per object is permitted.  From what I see in your code I would be inclined to combine the two statements into one as such:
    CASE WHEN dbo.ClientBudgetYear.DateStage1Approved > 01/01/1900 AND dbo.ClientBudgetMonth.Month in (11,12) THEN dbo.ClientBudgetMonth.Stage1Sales else null END
    Thanks,
    John

  • Help with decode or case statement

    I have the following insert statement
    insert into t_outcome (
    TRANSACTION_ID,
    charge_DATE,
    Charge_TIME,
    STATUS_CODE)
    values(cur_tem.transaction_id,
    cur_tem.charge_date,
    cur_tem.charge_time,
    cur_tem.STATUS_code)
    I require to incorporate the following rules into the population of charge_TIME
    if cur_tem.STATUS_code is 7 and cur_temp.charge_time is not null then populate charge_TIME with cur_temp.charge_time
    else if cur_tem.STATUS_code is 7 and cur_temp.charge_time is null then populate charge_TIME with -9
    else if cur_tem.STATUS_code is not 7 then populate charge_TIME with -7
    How do I add these rules into the insert statement ?
    Thanks
    Brendon

    decode(cur_tem.STATUS_code, 7, nvl(cur_tem.charge_time, -9), -7)
    I think that will work.
    Lee
    Message was edited by:
    Lee Forkenbrock

  • Help with Decode function

    Hello!!
    Can anyone please help me with the decode statement
    Table 1 Table2 Table3
    Id Id Code
    Volume Code
    For each of the codes in Table3 I need to find the corresponding Volume. Can I use decode in the select statement to this,
    Eg Code Volume
    ABC 20
    XYZ 10 etc etc.
    Thankyou all in advance.

    Your table structure is a little unclear from your post. I am assuming that what you posted was:
    Table 1
    Id
    Table2
    Id
    Code
    Table3
    Volume
    Code You can use decode if there are only a few values for table3. For example,
    SELECT table2.code,
    DECODE(table2.code,'ABC',10,'XYZ',20,'UNKNOWN') volume
    FROM table2
    or even
    SELECT code,DECODE(code,null,'NONE',
                      (SELECT volume FROM table3 where code=table2.code)) volume
    FROM table2However, the first will break, or at least be incorrect, if anyone adds a new code/volume pair, and is tedious if you have more than a few values. The second will likely be pretty slow if there are a large number of records in table3. The best solution would be to use a simple join rather than decode. Something like:
    SELECT table1.id, table2.code, table3.volume
    FROM table1, table2, table3
    WHERE table1.id = table2.id and
          table2.code = table3.code

  • Help with decode

    Let's call the field "xfieldx". It’s currently a char data type that either gets inputted as null or “y” meaning yes. The problem comes when the query counts the number of rows that have a non-null value. The sql is below
    sum(decode(xfieldx, null, 0, 'n', 0, 1)) as xfieldxCount
    still returns a char value and later, when subject to a numeric condition “>” it fails. I need to make sure that this count is occurring correctly. Any wisdom?

    Welcome to the forum!
    Whenever you have a question, please post a little sample data (CREATE TABLE and INSERT statements), and the results you have from that data, so that the people who want to help you can re-create the problem and test their ideas.
    If you have an existing query, post the complete query, point out where it's getting the wrong results, and explain how you'd get the right results in those places.
    Always say which version of Oracle you're uisng.
    Since this is your first post, I'll do some sample data for you:
    CREATE TABLE     table_x
    (       x_id     NUMBER (4)     PRIMARY KEY
    ,     xfieldx     VARCHAR2 (1)
    INSERT INTO table_x (x_id, xfieldx) VALUES (0, NULL);
    INSERT INTO table_x (x_id, xfieldx) VALUES (1, 'n');
    INSERT INTO table_x (x_id, xfieldx) VALUES (2, 'y');
    INSERT INTO table_x (x_id, xfieldx) VALUES (3, 'n');
    894540 wrote:Let's call the field "xfieldx". It’s currently a char data type that either gets inputted as null or “y” meaning yes. The problem comes when the query counts the number of rows that have a non-null value. The sql is below
    sum(decode(xfieldx, null, 0, 'n', 0, 1)) as xfieldxCount
    still returns a char value and later, when subject to a numeric condition “>” it fails. I need to make sure that this count is occurring correctly. Any wisdom?That DECODE doesn't return a CHAR; it returs a NUMBER, either 0 or 1. (You can't use SUM on a CHAR expression.) And it's guaranteed either 0 or 1, never NULL. If you're interested in how many of the rows have a non-NULL value, just use COUNT.
    The following query shows the difference:
    SELECT  SUM ( DECODE ( xfieldx
                         , NULL     , 0
                   , 'n'     , 0
                               , 1
             )               AS total_y
    ,       COUNT (xfieldx)          AS count_xfieldx
    FROM     table_x
    ;Output:
    `  TOTAL_Y COUNT_XFIELDX
             1             3This should work in any version of Oracle.
    What results are you trying to get?
    What are you trying to do with a > condition?

  • Need some help with a case statement implementation

    I am having trouble using a CASE statement to compare values and then display the results. The other issue is that i want to put these results in a separate column somehow.
    Heres how the code would look:
    SELECT "Task"."Code",
    "Stat" = CASE WHEN "Task.Code" = 1 THEN string
    ....and so on
    I wanted to make "Stat" the new column for the results, and string represents the string to be assigned if 1 was the value for code. I keep getting syntax error, any help would be nice.

    This is a lot easier than you might think.
    1) First, move another column of "Code" to your workspace.
    2) Click on the fx button and then on the BINS tab.
    3) Click on "Add BIN" and with the operand on "is equal to/is in," input 1 and then click "OK."
    4) Name this what you had for "string."
    Repeat for all the different values you want to rename as another "string" value.
    5) Finally, check the "custom heading" checkbox, and rename this column "Stat" as you indicated.
    That's it.

  • Help with a CASE!!!

    I did started a thread about the same problem this morning but no one couldn't help.
    I tried to write it my self , well, still not working out. When i try to ran it, it just freezes........ORA-01652: unable to extend temp segment by 64 in tablespace TEMP
    Can someone please see where is my problem with CASE..Im trying to put a case statment into WHERE.........
    All I want is if the gl_tr_type = 'SO' then execute the rest in the case statment if the transaction is not 'SO' or 'WE' then cust_name would be blank.......If it's blank then i need N/A inserted there
    This is what i need
    WHEN gl_tr_type = 'SO' and a.gl_doc = inv_nbr
    AND h.inv_cust_bill_to_nbr = g.cust_nbr
    and
    WHEN gl_tr_type = 'WE' and a.gl_doc = inv_code
    AND h.inv_cust_bill_to_nbr = g.cust_nbr
    Thank-you very much!!!!
    SELECT
    b.en_ent,
    e.sa_sub,
    c.cc_cstctr,
    d.acct_acc,
    b. EN_ENTITY_LNG,
    e. SA_SUB_LNG,
    c. COST_CTR_LNG,
    d. ACCT_ACC_LNG ,
              g. cust_name,
    f. FISCAL_MONTH,
    f. FISCAL_YEAR_LNG,
    d. ACCT_TYPE,
    SUM(a.gl_amt)
    FROM
    F_ACCT_TRX_HIST_STG1 a,
    D_ENTITY_STG2 b,
    D_COSTCTR_STG2 c,
    D_ACCTS_STG2 d,
    D_SUBACCTS_STG2 e,
    D_PERIOD_STG1 f,
    FINMART.D_CUSTOMER g,
    DSSMART.F_SALES_INVOICE h
    WHERE a.gl_eff_dt BETWEEN '02-april-2007' AND '15-april-2007' AND
    a.GL_ENT = b.EN_ENT AND
    c.CC_CSTCTR = UPPER (a.GL_CC) AND
    d.acct_acc = a.gl_acc AND
    e.sa_sub = a.gl_sa AND
    a.gl_eff_dt = f.calendar_date AND
    a.gl_doc =
    CASE WHEN a.gl_tr_type = 'SO'
    AND h.inv_cust_bill_to_nbr = g.cust_nbr
    THEN h.inv_nbr
    END
    GROUP BY b.EN_ENT, e.sa_sub, c.cc_cstctr, d.acct_acc,
    b. EN_ENTITY_LNG,
    e. SA_SUB_LNG,
    c. COST_CTR_LNG,
    d. ACCT_ACC_LNG ,
              g. cust_name,
    f. FISCAL_MONTH,
    f. FISCAL_YEAR_LNG,
    d. ACCT_TYPE

    Can someone please see where is my problem with
    CASE..Im trying to put a case statment into
    WHERE.........The select clause has a quite fixed structure, because it descripts the format of the result set, and the use of case statement add some more flexibility to this structure in order to make some changes to the result set that don't go in opposition with the output structure.
    SQL> select case
      2     when (rownum < 2) then
      3             1
      4     else
      5             sysdate
      6     end
      7  from dual
      8  connect by level < 5
      9  /
                    sysdate
    ERROR at line 5:
    ORA-00932: inconsistent datatypes: expected NUMBER got DATEThe where clause doesn't have such a fixed structure and has enought expressive power to implement any sort of condition.
    In your "case".
    WHERE
    CASE WHEN (( a.gl_tr_type = 'SO') AND (h.inv_cust_bill_to_nbr = g.cust_nbr)) THEN h.inv_nbr
    END
    /can be expressed with
    WHERE
    not(( a.gl_tr_type = 'SO') AND (h.inv_cust_bill_to_nbr = g.cust_nbr)) or (h.inv_nbr)
    /here is an example
    SQL> select rn,word
      2  from (
      3     select rownum as rn,to_char(to_date(rownum,'j'),'JSP') word
      4     from dual
      5     connect by level <= 10
      6  )
      7  where (not(rn <= 5) or ( length(word)=3 )) /*case  (rn < 5) then ( lenght(word)=3)*/
      8  /
            RN WORD
             1 ONE
             2 TWO
             6 SIX
             7 SEVEN
             8 EIGHT
             9 NINE
            10 TENBye Alessandro

  • Need help with DECODE

    Hi,
    I need to write a DECODE function to which if I pass 'mystring' and if it has the value 'M' it should output 'M', if it has a value of 'F' it should output 'F' and if mystring is not same as string_coded then it should output string_coded.
    I know the below statement is incorrect.
    decode (mystring, 'M', 'M', 'F', 'F', (mystring <> string_coded), string_coded)
    Is there a way to correct this DECODE? Please suggest.
    Thanks.

    It is not clear of you want it to match the string 'string_coded' or if it is some column name, but with the example below you should be able to figure out what to adjust to make it work in your case.
    SQL> create table mytable
      2  as
      3  select 'M' mystring, 'X' string_coded from dual union all
      4  select 'F', 'X' from dual union all
      5  select 'X', 'X' from dual union all
      6  select 'Z', 'X' from dual
      7  /
    Tabel is aangemaakt.
    SQL> select mystring
      2       , string_coded
      3       , decode(mystring,'M','M','F','F',string_coded,'mystring = string_coded','mystring != string_coded') your_expression
      4    from mytable
      5  /
    M S YOUR_EXPRESSION
    M X M
    F X F
    X X mystring = string_coded
    Z X mystring != string_coded
    4 rijen zijn geselecteerd.Regards,
    Rob.

  • Need help with switch/case

    Thanks in advance.
    I read the tut on switch statements. My assignment is asking me to do something that is not detailed in that explanation ;
    I have a total of 5 case statements, 1-4 and a default statement. The instructions for them are as follows:
    Case 1: If the user enters a 1, display a message that informs users they are correct, as any input canbe saved as a String. Enter the break statement.
    Case 2: If the user enters a 2, parse the value into tryInt. Display as message that informs the users they are correct. Enter the break statement.
    Case 3. If they user enters a 3, parse the value into tryDouble. Display a message tha t informs users they are correct. Enter the break statement.
    Case 4: Set done equal to true. Enter code to display a closing message. Enter a break statement.
    Case default: throw a new NumberFormatException.;
    Here is the code
    import java.io.*;
    import javax.swing.JOptionPane.*;
    public class MyType1
         public static void main(String[] args)
              //declaring variables
              String strChoice, strTryString, strTryInt, strTryDouble;
              int choice, tryInt;
              double tryDouble;
              boolean done = false;
              //loop while not done
              while (!done)
                   try
                        choice = Integer.parseInt(strChoice);
                        switch(choice)
                             case 1:
                                  JOptionPane.showMessageDialog(null,"You are correct!");
                                  break;
                             case 2:
                                  choice = Integer.parseInt(tryInt); JOptionPane.showMessageDialog(null,"You are correct!");
                                  break;
                             case 3:
                                  choice = Double.parseDouble(tryDouble);
                                  JOptionPane.showMessageDialog(null,"You are correct!");
                                  break;
                             case 4:
                                  done = true; JOptionPane.showMessageDialog(null,"Goodbye!");
                                  break;
    As usual Im doing something wrong. Please help.

    Thanks for your input. The directions for the assignment tells me to first declare the variables.
    Begin a while(!done) loop to repeat as long as teh user does not click the Cancel button.
    Inside a try statement, enter code to display an input box with three choices.
    Type choice = Integer.parseInt(strChoice); on the next line to parse the value for the choice entered by the user.
    (HERE THE SWITCH STATEMENT WITH CAST STATEMENTS)
    Close the switch statement with brackets
    Create a catch statement.
    import java.io.*;
    import javax.swing.JOptionPane.*;
    public class MyType1
         public static void main(String[] args)
              //declaring variables
              String strChoice, strTryString, strTryInt, strTryDouble;
              int choice, tryInt;
              double tryDouble;
              boolean done = false;
              //loop while not done
              while (!done)
                   try
                        String message = "What is My Type:" + "\n\n1) String\n2)Integer\n3)double\n4)Quit the program\n\n";
                        choice = Integer.parseInt(strChoice);
                        //test for valid choice 1, 2, 3, or 4
                        if (choice<1 || choice>4) throw new NumberFormatException();
                        else done = true;
                        switch(choice)
                             case 1:
                                  JOptionPane.showMessageDialog(null,"You are correct!");
                                  break;
                             case 2:
                                  choice = Integer.parseInt(tryInt); JOptionPane.showMessageDialog(null,"You are correct!");
                                  break;
                             case 3:
                                  choice = Double.parseDouble(tryDouble);
                                  JOptionPane.showMessageDialog(null,"You are correct!");
                                  break;
                             case 4:
                                  done = true; JOptionPane.showMessageDialog(null,"Goodbye!");
                                  break;
                   catch (NumberFormat Exception e)
                        JOptionPane.showMessageDialog(null, "Please enter a 1, 2, 3 or 4:",  "Error", JOptionPane.INFORMATION_MESSAGE);
              }Typing this now, I see I dont have anything in my try statement entering code to display an input box with three choices.
    (PS. I know I would write a catch statement for the NumberFormatException, but why would I also write this exception in the case statement also??)

  • I need to find someone to help with a case # from a previous chat

    On 11/17 I chatted online with a gentleman for quite a while discussing a printhead issue. He gave me a case # and sent me new ink to try. That did not work and I have been trying to contact someone to resume the conversation. I was to;ld the printer would then have to be replaced. It is still under warranty. Now I cannot find any help online.

    I will ask to have an HP support agent contact you via private message.  Do not post any private information (including contact information, case ID's or serial numbers) in the forum here, but you can supply this to the agent in private message if requested.
    To access messages look for a number next to the envelope in the upper right of the page.  Click on the envelope to read messages.
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • Help with Switch-Case Statement

    How do you get this in a switch-case statement or work with it?
              if (age < 70) {
                        JOptionPane.showMessageDialog(null, "People that are below the 70s are nothing special.");
              else if (age > 69 && age < 80) {
                        JOptionPane.showMessageDialog(null,  "People that are in their 70s are called septuagenarian.");
              else if (age > 79 && age < 90) {
                        JOptionPane.showMessageDialog(null,  "People that are in their 80s are called octogenarian.");
              else if (age > 89 && age < 100) {
                        JOptionPane.showMessageDialog(null,  "People that are in their 90s are called nonagenarian.");
              else (age > 99 && age < 110) {
                        JOptionPane.showMessageDialog(null,  "People that are in their 100s are called centenarian.");
                   }Thanks~

    As per Java Specification, swtich case expects an integer and boolean cannot be used as param for switch.
    In your case switch can be used like this.
    int index = age /10;
    switch(index) {
    case 1:
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
    Your First case
    break;
    case 7:
    your second case
    break;
    case 8:
    third case
    break;
    case 9:
    fourth case
    break;
    default:
    fifth case
    break;
    Take note of the break statements. Its very important. But I wont prefer in this case. Code looks awkward and is not so meaningful.....

  • Help With A Case Statement With Multiple Variables

    I apologize if this is the incorrect Forum for this type of question, but it was the closest one that I could find. I'm pretty new with SQL and am stuck on this issue. I have roughly 26 dates that I need to compare to one another. Each date is tied to a step code. I also have a Stop value that is tied directly to the "max date" of the step codes. So, I need to compare 30 dates against one another to 1st - ID the max date; 2nd - ID if the Stop value is correct; 3rd - if the stop value is incorrect, identify what the correct value would be.
    At first, this seemed like it wouldn't be that hard. I wrote a query that found the max date for each step code. Then I realized that multiple step codes could have the same date. So, I tried using this case statement, but I did not get the expected results. Is there a more efficient way of getting what I need? This code seems like it's not necessary and probably the source of my issue.
    CASE
    WHEN FS25.ACTUAL_COMPLETION_DATE > FS.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS1.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS2.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS3.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS4.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS5.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS6.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS7.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS8.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS9.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS10.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS11.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS12.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS13.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS14.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS15.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS16.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS17.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS18.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS19.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS20.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS21.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS22.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS23.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS24.ACTUAL_COMPLETION_DATE AND L.FORECLOSURE_STOP_CODE <= '8' THEN '9'
    ELSE 'UH OH'
    END AS "CHANGE FC STOP TO"
    Any assistance is appreciated!

    I think Igor pointed out a working solution before.
    Applying it at your examples (you missed the operator after STOP_CODE, I assume it =):
    CASE
    WHEN FS25 = GREATEST(FS25, FS24, FS23) AND STOP_CODE = '9' THEN '9'
    ELSE 'UH OH'
    END AS 'CHANGE STOP CODE TO'
    {code}
    Be careful at the second example. You are checking:
    {code:sql}
    FS25 > FS24 OR FS25 IS NOT NULL AND FS24 IS NULL AND FS25 > FS23
    OR
    FS25 IS NOT NULL AND FS23 IS NULL AND STOP_CODE = '9'
    {code}
    Remember that AND has higher priority among operators than OR so if FS25 is greater than FS24 and FS23 the condition will be true even if STOP_CODE is not equal 9.
    Regards.
    Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for