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.....

Similar Messages

  • 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

  • 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

  • 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??)

  • 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 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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Need help about switch & case statements

    Dear friends
    I am new student of Java
    Our University gave us project to make a program. Here is the program:
    a- Write a java program ,so the user can input the monthly salary then compute the net salary of an employee after deducting the tax ,use the following table to calculate the tax .Note use switch statement .
    Annual salary Tax
    100- 999 0
    1000- 1999 5%
    2000- 3999 7%
    4000- 7000 10%
    7000 13%Please help me how could I use switch statement.
    All I know about switch statement is that I have use Integers for selection.
    Kindly help me. I have only 2 days to submit my assignment.
    Thanks in Advance
    Edited by: syedejaz on Aug 13, 2008 8:09 AM
    Edited by: syedejaz on Aug 13, 2008 8:10 AM

    Hello every body:
    I tried to make my first program using if then else but the problem is that no calcuation is happinig
    /*  TMA01 ITC250, Part-III, a
      Program which gets input monthly salary and shows net salary after deducting given tax.
    File: netSalary.java
    import javax.swing.*;
    import java.text.*;
    public class netSalary {
    public static void main(String[] args) {
           int Salary=0,Tax=0,monthlySalary=0;
           monthlySalary= Integer.parseInt(JOptionPane.showInputDialog(null, "Enter Monthly Salary:"));
           if ((monthlySalary>=100) && (monthlySalary<=999)) {
                Tax = (monthlySalary*(0/100));
          Salary = (monthlySalary-Tax);
         JOptionPane.showMessageDialog(null, "Net Salary is:" +Salary);
            } else if ((monthlySalary>=1000) && (monthlySalary<=1999)) {
                Tax = (monthlySalary*(5/100));
         Salary = (monthlySalary-Tax);
         JOptionPane.showMessageDialog(null, "Net Salary is:" +Salary);
            } else if (monthlySalary>=2000 && monthlySalary<=3999) {
                Tax = (monthlySalary*(7/100));
         Salary = (monthlySalary-Tax);
         JOptionPane.showMessageDialog(null, "Net Salary is:" +Salary);
            } else if (monthlySalary>=4000 && monthlySalary<=7000) {
                Tax = (monthlySalary*(10/100));
         Salary = (monthlySalary-Tax);
         JOptionPane.showMessageDialog(null, "Net Salary is:" +Salary);
            } else {
                Tax = (monthlySalary*(13/100));
         Salary = (monthlySalary-Tax);
         JOptionPane.showMessageDialog(null, "Net Salary is:" +Salary);
    } The tax is not detuting. please tell me the mistake
    Edited by: syedejaz on Aug 13, 2008 2:49 PM

  • Need Help With A Case Statement.

    Apex 3.2
    I currently have a report with the sql
    select oid oid,
    APEX_ITEM.MD5_CHECKSUM(oid, jobid, gdc, status)||
    apex_item.hidden(2,oid)||
    apex_item.display_and_save(3,jobid) jobid,
    apex_item.display_and_save(4,gdc) gdc,
    apex_item.display_and_save(5,bday) bday,
    num_rows num_rows,
    status current_status,
    APEX_ITEM.SELECT_LIST_FROM_LOV(6,status,'WORKLOAD_STATUS_FULL_LIST',null,'YES',null,'-Select-') new_status,
    case
        when status in ('TO_TABLE','ERROR_TABLE') then 'PREPARED'
        when status in ('TO_FILE','ERROR_FILE') then 'IN_TABLE'
        when status like '%SEND%' and status <> 'SEND_RENAME_OK' then 'IN_FILE'
        when trim(translate(status,'-1234567890',' ')) is null then to_char(jobid)
        else status
      end status_if_reset
    from scp_workload
    where jobid = :P28_JOBIDWhat I want to do is, if the result of status_if_reset column
    is not in ('PREPARED','EMPTY_FILE','IN_FILE','SEND_RENAME_OK','DEPRICIATED')
    then the new_status status column should be the APEX_ITEM.SELECT_LIST_FROM_LOV.
    If not it should just be status (normal report column)
    Hope I have explained properly
    Gus

    Your function had errors but maybe that was copy paste. The way you wrote your code is way to complicated. This should work for you:
    CREATE OR REPLACE FUNCTION fn_28_get_status (p_status IN VARCHAR2)
       RETURN NUMBER
    AS
       v_status   NUMBER;
    BEGIN
       IF    p_status IN
                ('TO_TABLE', 'ERROR_TABLE', 'TO_FILE', 'ERROR_FILE',
                 'SEND_RENAME_OK')
          OR p_status LIKE '%SEND%'
       THEN
          v_status := 1;
       ELSE
          v_status := 0;
       END IF;
       RETURN v_status;
    END fn_28_get_status;
    SELECT OID OID,
              apex_item.md5_checksum (OID, jobid, gdc, status)
           || apex_item.hidden (2, OID)
           || apex_item.display_and_save (3, jobid) jobid,
           apex_item.display_and_save (4, gdc) gdc,
           apex_item.display_and_save (5, bday) bday, num_rows num_rows,
           status current_status,
           CASE
              WHEN fn_28_get_status (status) = 1
                 THEN apex_item.select_list_from_lov
                                         (9,
                                          status,
                                          'WORKLOAD_STATUS_FULL_LIST',
                                          NULL,
                                          'YES',
                                          NULL,
                                          '-Select-'
              ELSE status
           END new_status
      FROM scp_workload
    WHERE jobid = :p28_jobidYou should not expect the others will debug you code. They don't have your objects to test.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.apress.com/9781430235125
    https://apex.oracle.com/pls/apex/f?p=31517:1
    http://www.amazon.de/Oracle-APEX-XE-Praxis/dp/3826655494
    -------------------------------------------------------------------

  • Need help with this CASE statement

    Hi everyone,
    I would like to create a CASE that references another view and uses fields in that view to create a new field in a new view.
    The fields I am working with are called LEVEL_CD and AVAILABLE_AMT.
    In this case I would like to create a field called AVAILABLE_AMT (in my new view) that inserts the AVAILABLE_AMT from the old view into the new field only if the LEVEL_CD = 1. If the LEVEL_CD is anything else but 1 I would like to insert a 0 into my new
    AVAILABLE AMOUNT field.
    This is what I have so far and it doesn't seem to work:
    CASE WHEN old_view.LEVEL_CD = 1 THEN old_view.AVAILABLE_AMT
    WHEN old_view.LEVEL_CD <> 1 THEN 0 END AS AVAILABLE_AMT
    This just gives me zeroes in every record. Can anybody spot what I am doing wrong?
    Thanks!

    SELECT <columns>,CASE WHEN old_view.LEVEL_CD
    =
    1
    THEN old_view.AVAILABLE_AMT
    ELSE 0 END AS AVAILABLE_AMTFROM old_view.PK JOIN new_view.PK WHERE....PS.PK -Primary Key
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Can I test (junit) default case of switch-case statement ?

    Hi,
    I have a class which has switch-case statements and I am trying to junit test with 100% coverage. My switch-case workes based on enum values.
    say my enum values are 1, 2.
    switch(getEnumValues) {
    case 1:
    return "some value";
    case 2:
    return "some value";
    default:
    throw new UnsupportedOperationException("No such enum value supported.");
    I have test case to test the case 1 and 2 but I am not able to test default case. Can anyone please let me know how can I right a junit test case for default case.
    Edited by: TUIJAVADEV on Nov 4, 2008 4:15 PM

    yawmark wrote:
    TUIJAVADEV wrote:
    I have test case to test the case 1 and 2 but I am not able to test default case. Can anyone please let me know how can I right a junit test case for default case.If your enum values are ONE and TWO, and you have cases for both, then there is no "default case". There is nothing to test.
    ~If I'm reading the OP correctly, they're 1 and 2, not ONE and TWO. That is, not values of a Java enum.
    If this is the case, then the easiest way to test the default case is to break the swtich out into a separate, package-accessible method that takes and arg and passes that onto the switch. (There may be variations on this, depending on how your code is structured.)
    However, in a similar vein to what the others are saying, if you already know that you'll only ever have 1 and 2 by the time you get to the switch (maybe because the value comes from an argument to the enclosing method, and you've already unit tested that it appropriately throws an IllegalArgumentException when other values are passed, then there's no need to test the default.
    Finally, though if it is ints 1 and 2, rather than a true enum, why not switch to an enum?

  • Need help with the session state value items.

    I need help with the session state value items.
    Trigger is created (on After delete, insert action) on table A.
    When insert in table B at least one row, then trigger update value to 'Y'
    in table A.
    When delete all rows from a table B,, then trigger update value to 'N'
    in table A.
    In detail report changes are visible, but the trigger replacement value is not set in session value.
    How can I implement this?

    You'll have to create a process which runs after your database update process that does a query and loads the result into your page item.
    For example
    SELECT YN_COLUMN
    FROM My_TABLE
    INTO My_Page_Item
    WHERE Key_value = My_Page_Item_Holding_Key_ValueThe DML process will only return key values after updating, such as an ID primary key updated by a sequence in a trigger.
    If the value is showing in a report, make sure the report refreshes on reload of the page.
    Edited by: Bob37 on Dec 6, 2011 10:36 AM

  • DoGet method is called 2 times when a switch-case statement is used

    Hello all,
    I have a servlet that, when run from browser, runs the doGet method 2 times.
    I have a switch case statement within the servlet and when I comment out this servlet, it runs 1 time as expected.
    Here is the code:
    public class RSSServlet extends HttpServlet {
        /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
         * @param request servlet request
         * @param response servlet response
        protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            System.out.println("CALLED SERVLET");
            response.setContentType("text/xml;charset=UTF-8");
            PrintWriter out      = response.getWriter();
            DBQueriesRSS queries = new DBQueriesRSS();
            String queryType     = request.getParameter("queryType");
            String strCount      = request.getParameter("count");
            int count            = (strCount != null && !strCount.equalsIgnoreCase("null") && strCount.length() > 0) ?
                Integer.parseInt(strCount) : 25;
             if(queryType != null && !queryType.equalsIgnoreCase("null") && queryType.length() > 0) {
                System.out.println("IN IF STATEMENT");
                switch(Integer.parseInt(queryType)) {
                    case 1 : out.println(queries.getDefault(count));System.out.println("1");       break;
                    case 11: out.println(queries.getDefault(count));System.out.println("11");       break;
                    case 21: out.println(queries.getTopDaily(count));System.out.println("21");      break;
                    case 22: out.println(queries.getTopWeekly(count));System.out.println("22");     break;
                    case 23: out.println(queries.getTopMonthly(count));System.out.println("23");    break;
                    case 24: out.println(queries.getTopYearly(count));System.out.println("24");     break;
                    case 31: out.println(queries.getTopNDailyBW(count));System.out.println("31");   break;
                    case 32: out.println(queries.getTopNWeeklyBW(count));System.out.println("32");  break;
                    case 33: out.println(queries.getTopNMonthlyBW(count));System.out.println("33"); break;
                    case 34: out.println(queries.getTopNYearlyBW(count));System.out.println("34");  break;
                    default: out.println(queries.getTopWeekly(25));System.out.println("default");    break;
                System.out.println("OUT OF SWITCH");
            System.out.println("OUT OF IF");
            out.close();
        // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
        /** Handles the HTTP <code>GET</code> method.
         * @param request servlet request
         * @param response servlet response
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            processRequest(request, response);
        /** Handles the HTTP <code>POST</code> method.
         * @param request servlet request
         * @param response servlet response
        protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
           processRequest(request, response);
        /** Returns a short description of the servlet.
        public String getServletInfo() {
            return "Short description";
        // </editor-fold>
    } The results from running this servlet are:
    http://localhost/proxy/RSSServlet??queryType=34&count=66
    CALLED SERVLET
    IN IF STATEMENT
    34
    OUT OF SWITCH
    OUT OF IF
    CALLED SERVLET
    IN IF STATEMENT
    34
    OUT OF SWITCH
    OUT OF IFAnyone see anything obvious?
    TIA!

    in your case you want 'count' to be a class attribute rather than a local variable. But yes, incrementing it each time that the method is called will serve your purpose.

  • Help with this update statement..

    Hi everyone,
    I am trying to update a column in a table .I need to update that column
    with a function that takes patient_nbr and type_x column values as a parameter.
    That table has almost "300,000" records. It is taking long time to complete
    almost 60 min to 90 min.
    Is it usual to take that much time to update that many records?
    I dont know why it is taking this much time.Please help with this update statement.
    select get_partner_id(SUBSTR(patient_nbr,1,9),type_x) partner_id from test_load;
    (it is just taking 20 - 30 sec)
    I am sure that it is not the problem with my function.
    I tried the following update and merge statements .Please correct me if i am wrong
    in the syntax and give me some suggestions how can i make the update statement fast.
    update test_load set partner_id = get_partner_id(SUBSTR(patient_nbr,1,9),type_x);
    merge into test_load a
    using (select patient_nbr,type_x from test_load) b
    on (a.patient_nbr = b.patient_nbr)
    when matched
    then
    update
    set a.partner_id = get_partner_id(SUBSTR(b.patient_nbr,1,9),b.type_x);
    there is a index on patient_nbr column
    and the statistics are gathered on this table.

    Hi Justin,
    As requested here are the explain plans for my update statements.Please correct if i am doing anything wrong.
    update test_load set partner_id = get_partner_id(SUBSTR(patient_nbr,1,9),type_x);
    "PLAN_TABLE_OUTPUT"
    "Plan hash value: 3793814442"
    "| Id  | Operation          | Name             | Rows  | Bytes | Cost (%CPU)| Time     |"
    "|   0 | UPDATE STATEMENT   |                  |   274K|  4552K|  1488   (1)| 00:00:18 |"
    "|   1 |  UPDATE            |        TEST_LOAD |       |       |            |          |"
    "|   2 |   TABLE ACCESS FULL|        TEST_LOAD |   274K|  4552K|  1488   (1)| 00:00:18 |"
    merge into test_load a
    using (select patient_nbr,type_x from test_load) b
    on (a.patient_nbr = b.patient_nbr)
    when matched
    then
    update
    set a.partner_id = get_partner_id(SUBSTR(b.patient_nbr,1,9),b.type_x);
    "PLAN_TABLE_OUTPUT"
    "Plan hash value: 1188928691"
    "| Id  | Operation            | Name             | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |"
    "|   0 | MERGE STATEMENT      |                  |   274K|  3213K|       |  6660   (1)| 00:01:20 |"
    "|   1 |  MERGE               |        TEST_LOAD |       |       |       |            |          |"
    "|   2 |   VIEW               |                  |       |       |       |            |          |"
    "|*  3 |    HASH JOIN         |                  |   274K|    43M|  7232K|  6660   (1)| 00:01:20 |"
    "|   4 |     TABLE ACCESS FULL|        TEST_LOAD |   274K|  4017K|       |  1482   (1)| 00:00:18 |"
    "|   5 |     TABLE ACCESS FULL|        TEST_LOAD |   274K|    40M|       |  1496   (2)| 00:00:18 |"
    "Predicate Information (identified by operation id):"
    "   3 - access("A"."patient_nbr"="patient_nbr")"Please give some suggestions..
    what's the best approach for doing the updates for huge tables?
    Thanks

  • Please i need help with switch from the us store to malaysian store how i can switch

    Please i need help with switch from the us store to malaysian store how i can switch

    Click here and follow the instructions to change the iTunes Store country.
    (82303)

  • Help with Switch statements using Enums?

    Hello, i need help with writing switch statements involving enums. Researched a lot but still cant find desired answer so going to ask here. Ok i'll cut story short.
    Im writing a calculator program. The main problem is writing code for controlling the engine of calculator which sequences of sum actions.
    I have enum class on itself. Atm i think thats ok. I have another class - the engine which does the work.
    I planned to have a switch statement which takes in parameter of a string n. This string n is received from the user interface when users press a button say; "1 + 2 = " which each time n should be "1", "+", "2" and "=" respectively.
    My algorithm would be as follows checking if its a operator(+) a case carry out adding etc.. each case producing its own task. ( I know i can do it with many simple if..else but that is bad programming technique hence im not going down that route) So here the problem arises - i cant get the switch to successfully complete its task... How about look at my code to understand it better.
    I have posted below all the relevant code i got so far, not including the swing codes because they are not needed here...
    ValidOperators v;
    public Calculator_Engine(ValidOperators v){
              stack = new Stack(20);
              //The creation of the stack...
              this.v = v;          
    public void main_Engine(String n){
           ValidOperators v = ValidOperators.numbers;
                    *vo = vo.valueOf(n);*
         switch(v){
         case Add: add();  break;
         case Sub: sub(); break;
         case Mul: Mul(); break;
         case Div: Div(); break;
         case Eq:sum = stack.sPop(); System.out.println("Sum= " + sum);
         default: double number = Integer.parseInt(n);
                       numberPressed(number);
                       break;
                      //default meaning its number so pass it to a method to do a job
    public enum ValidOperators {
         Add("+"), Sub("-"), Mul("X"), Div("/"),
         Eq("="), Numbers("?"); }
         Notes*
    It gives out error: "No enum const class ValidOperators.+" when i press button +.
    It has nothing to do with listeners as it highlighted the error is coming from the line:switch(v){
    I think i know where the problem is.. the line "vo = vo.valueOf(n);"
    This line gets the string and store the enum as that value instead of Add, Sub etc... So how would i solve the problem?
    But.. I dont know how to fix it. ANy help would be good
    Need more info please ask!
    Thanks in advance.

    demo:
    import java.util.*;
    public class EnumExample {
        enum E {
            STAR("*"), HASH("#");
            private String symbol;
            private static Map<String, E> map = new HashMap<String, E>();
            static {
                put(STAR);
                put(HASH);
            public String getSymbol() {
                return symbol;
            private E(String symbol) {
                this.symbol = symbol;
            private static void put(E e) {
                map.put(e.getSymbol(), e);
            public static E parse(String symbol) {
                return map.get(symbol);
        public static void main(String[] args) {
            System.out.println(E.valueOf("STAR")); //succeeds
            System.out.println(E.parse("*")); //succeeds
            System.out.println(E.parse("STAR")); //fails: null
            System.out.println(E.valueOf("*")); //fails: IllegalArgumentException
    }

Maybe you are looking for

  • My text tool is not working.

    When I try to add text using the text tool the screen turns pink and creates blurry text, or it says there was an error. How do I fix this?

  • ITunes doesn't open, box says "QuickTime was not found."

    My iTunes won't open, the box say's "QuickTime was not found. QuickTime is required to run iTunes." Help!

  • HTMLB TableView in customer CI/CD layout

    Hello, i want to create a BSP with htmlb tableview, so i can simply use the given features (sorting, filter, ...) but the customer want to adapt hic CI/CD Colours Blue and Orange to the hole application. Is there a chance to use a own stylesheet inst

  • Failing IP communication across the network with 3750x

    Hi! I'm facing a very odd problem. A week ago I've installed a 3750x on a client.  On it, was connected, a Lan2Lan fiber channel(with IP associated directly to   the interface) and a MPLS link(over a Cisco 2901) interconnecting a branch,   and severa

  • While compiling .pll file , plx  file is not creating .

    Hi , While i try to compile .pll file in oracle forms 6i in my local machine , it is compiling without errors . but it is not generating .plx file. Can any one please tell me what could be the reason. Thanks in advance, Sanjeev.