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

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

  • 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

  • Help: How to include logic in multiple CASE statements.

    Hello Folks,
    I have this Query where am converting from Access to Oracle. Am little confused on how to write multiple CASE statements.Apprecitae your help.
        round(Sum(IIf(recovery_flg = 'NONCASH FEE RECEIVED',
                         IIf(feepaid < FEE, FEE - FEEPAID, FEE),
                         0)),
                 2)

    *(1) you can nest CASE* - CASE in a CASE
    CASE WHEN ecovery_flg = 'NONCASH FEE RECEIVED' THEN
         CASE WHEN feepaid < FEE THEN ....
         END
    ENDor
    *(2) you can try to rewrite it as one CASE*
    CASE WHEN ecovery_flg = 'NONCASH FEE RECEIVED' AND feepaid < FEE THEN...
         WHEN ecovery_flg = 'NONCASH FEE RECEIVED' AND feepaid >= FEE THEN ...
    END

  • How to optimized Multiple CASE statement

    Hi..
    Somebody please help me out to use most optimized Multiple CASE statement in below example.. 
    Select
    CAST(COUNT(DISTINCT(CASE WHEN period_id <350 THEN period_id END)) AS DECIMAL(30,0))  AS Column1,                  CAST(COUNT(DISTINCT(CASE WHEN period_id >=351 AND period_id<=375 THEN period_id END))
    AS DECIMAL(30,0)) AS Column2,                                
    CAST(COUNT(DISTINCT(CASE WHEN period_id >=376 AND period_id<=400 THEN period_id END)) AS DECIMAL(30,0)) AS Column3,                             
    CAST(COUNT(DISTINCT(CASE WHEN period_id >=401 AND period_id<=450 THEN period_id END)) AS DECIMAL(30,0)) AS Column4,                             
    CAST(COUNT(DISTINCT(CASE WHEN period_id >=451 AND period_id<=575 THEN period_id END)) AS DECIMAL(30,0)) AS Column5,
    CAST(COUNT(DISTINCT(CASE WHEN pmc ='UVS' THEN pmc END)) AS DECIMAL(30,0)) AS Column6,                                
    CAST(COUNT(DISTINCT(CASE WHEN pmc ='VAL' THEN pmc END)) AS DECIMAL(30,0)) AS Column7                            
    FROM [Table1]
    Thanks in Advance,
    Deepak Goyal

    How is an index going to help in a query with no where clause or join?
    Rhetorical question but it brings to light the problem.  This query is going to produce a table/index scan precisely because there's no where clause.
    You need to change the way you are thinking about the problem.  The problem isn't that you need a better performing case statement, the problem is that you need to minimize the number of records you ask SQL Server to read from disk.  You do that
    by using a where clause or by joining to a smaller table.
    Here's one option which should give you the desired results while performing much better:
    create index idx_period_id on Table1 (period_id)
    create index idx_pmc on Table1 (pmc) include (period_id)
    select (select count(distinct period_id) from Table1 where period_id < 350) as Column1,
    (select count(distinct period_id) from Table1 where period_id between 351 and 375) as Column2,
    (select count(distinct period_id) from Table1 where period_id between 376 and 400) as Column3,
    (select count(distinct period_id) from Table1 where period_id between 401 and 450) as Column4,
    (select count(distinct period_id) from Table1 where period_id between 451 and 575) as Column5,
    (select count(distinct period_id) from Table1 where pmc = 'UVS') as Column6,
    (select count(distinct period_id) from Table1 where pmc = 'VAL') as Column7

  • 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

  • Help with multiple httpservice calls

    I need help with multiple httpservice call back to back, doing 10 different mysql query at startup of the app loading results into 14 datagrids/combobox all queries are to different tables.

    Hello,
    I think what Grizzzzzzzzzz means is the following:
        <mx:HTTPService id="serviceOne"
            url="here goes url"
            result="resultHandler1(event);"
            fault="faultHandler(event);"/>
        <mx:HTTPService id="serviceTwo"
            url="here goes url"
            result="resultHandler2(event);"
            fault="faultHandler(event);"/>
        <mx:HTTPService id="serviceThree"
            url="here goes url"
            result="resultHandler3(event);"
            fault="faultHandler(event);"/>
         // Result handler 1
         private function resultHandler1(event:ResultEvent):void{
              //Here do something with the results
             xmlCollection = event.result as XML;
             //then call the next service
             serviceTwo.send();
          // Result handler 2
          private function resultHandler2(event:ResultEvent):void{
              //Here do something with the results
             xmlCollection = event.result as XML;
             //then call the next service
              serviceThree.send();
    I hope this helps,
    Pierre

  • 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

  • Help With Multiple Schemas In Multiple Environments

    Dear Oracle Forum:
    We have a bit of controversy around the office and I was hoping we could get some expert input to get us on the right track.
    For the purposes of this discussion, we have two machines, development and production. Currently, on each machine, we have one database with multiple schemas, say, one for sales data and another for inventory. The sales data has maybe 200 tables and the inventory has another 50. About 12 times a year, once a month, we have a release and move code from dev to prod. The database is accessed by several hundred Pro*C and Pro*Cobol programs for online transaction processing.
    The problem comes up when we need to have multiple development environments. If I need to work on something for May that requires the customer address field to be 50 characters and somebody else is working on something for July that requires the customer address field to be 100 characters, we can’t both function in the same schema. We have a method of configuring running programs to attach to a given schema/database. Currently, everything connects to the same place. We were told that we should not have the programs running as the owners of the schemas for some reason so we set up additional users. The SALES schema is accessed with the connect string: SALES_USER/[email protected]. (I don’t know where we got dot world from but that is not the current discussion.)
    One of the guys said that we should have 12 copies of the database running, which is kind of painful to think about in my opinion. Oracle is not a lightweight product and there are any number of ancillary processes that would have to be duplicated 12 times.
    My recommendation is that we have 12 schemas each for sales and inventory with 12 users each to access them. We would have something like JAN_SALES_USER, FEB_SALES_USER, etc. Each user would have synonyms set up for each of the tables it is interested in. When my program connects as MAY_SALES_USER, I could select from the customer table and I would get my 50 character address field. When the other user connects as JUL_SALES_USER, he would get his 100 character address field. Both of us would not know anything different.
    Another idea that came up is to have a logon trigger that would set the current schema for that user to the appropriate base schema. When JUL_SALES_USER logs in, the current schema would be set to JUL_SALES, etc. This would simplify things by allowing us to avoid having something like 2400 synonyms to maintain (which could be automated without too much difficulty) but it would complicate things by requiring a trigger.
    There are probably other ways to go about this we have not considered as yet. Any input you can give will be appreciated.
    Regards,
    /Bob Bryan

    Hans Forbrich wrote:
    I'd rather see you with 12 schemas than with 12 databases. Unless you have lots of CPUs to spare ... and lots of cash to pay for those extra CPU licenses.
    Then again, I'd take it one step further and ask to investigate the base design. There should be little reason to change the schema based on time. Indeed, from what little I know of your app, I'd have to ask whether adding a 'date' column and appropriate views or properly coded SQL statements might simplify things. Interesting. If we were to have one big Customer table with views for each month, how would we handle the case where the May people have to see 50 character address and July have to see a 100 character address field. I guess we could have MAY_ADDRESS VARCHAR2(50) and JULY_ADDRESS VARCHAR2(100) and take care to make sure that people connecting as May can only see the May columns, etc. This is simpler than multiple schemas?
    I may have overly simplified things in my effort to get something down that would not require too much explanation. The big thing is that multiple people are doing development and they have to be independent of each other. If we were to drop a column for July, the May people will have trouble compiling if we don’t keep things separate. It is not a case of making the data available. The data in development is something we cook up to allow us to test. The other part is the code we compile now will be released to production one of these times. In production, there is only a need for one database.
    We are moving from another database product where multiple databases are effectively different sets of files. We have lots of disk space so multiple databases were no problem. Oracle is such a powerful product; I can’t believe there is not some way to set up something similar.

  • Having Trouble with nested Case Statements

    Hi Folks,
    I'm having trouble getting my head round nested case statements. For the life of me I cannot see what I'm missing here (unless my approach is all wrong).
    Any help much appreciated.
    Script:
    set serveroutput on format wrapped
    set feedback off
    set linesize 150
    DECLARE
    /* Set supported version here */
    ora_version VARCHAR2(4);
    unsupp_version EXCEPTION;
    /* Archive Log Info */
    db_log_mode VARCHAR2(12);
    BEGIN
    SELECT SUBSTR(VERSION, 1, 4)
    INTO ora_version
    FROM v$instance;
    SELECT log_mode
    INTO db_log_mode
    FROM v$database;
    CASE
    WHEN ora_version = '10.2' THEN
    DECLARE
    TYPE t_db IS RECORD(
    dflsh VARCHAR2(3),
    dcscn NUMBER);
    v_db t_db;
    BEGIN
    CASE
    WHEN db_log_mode = 'ARCHIVELOG' THEN
    EXECUTE IMMEDIATE 'SELECT INITCAP(flashback_on), current_scn FROM v$database'
    INTO v_db;
    DBMS_OUTPUT.PUT_LINE(' Flashback On : ' || v_db.dflsh);
    DBMS_OUTPUT.PUT_LINE(' Current SCN : ' || v_db.dcscn);
    DBMS_OUTPUT.PUT_LINE(' Log Mode : ' || db_log_mode);
    DBMS_OUTPUT.PUT_LINE(' Version : ' || ora_version);
    END;
    ELSE
    DBMS_OUTPUT.PUT_LINE(' Log Mode : ' || db_log_mode);
    DBMS_OUTPUT.PUT_LINE(' Version : ' || ora_version);
    END CASE;
    END;
    WHEN ora_version = '9.2' THEN
    DECLARE
    TYPE t_db IS RECORD(
    dcscn NUMBER);
    v_db t_db;
    BEGIN
    CASE
    WHEN db_log_mode = 'ARCHIVELOG' THEN
    EXECUTE IMMEDIATE 'SELECT current_scn FROM v$database'
    INTO v_db;
    DBMS_OUTPUT.PUT_LINE(' Current SCN : ' || v_db.dcscn);
    DBMS_OUTPUT.PUT_LINE(' Log Mode : ' || db_log_mode);
    DBMS_OUTPUT.PUT_LINE(' Version : ' || ora_version);
    END;
    ELSE
    DBMS_OUTPUT.PUT_LINE(' Log Mode : ' || db_log_mode);
    DBMS_OUTPUT.PUT_LINE(' Version : ' || ora_version);
    END CASE;
    END;
    ELSE
    RAISE unsupp_version;
    END CASE;
    EXCEPTION
    WHEN unsupp_version THEN
    DBMS_OUTPUT.PUT_LINE('');
    DBMS_OUTPUT.PUT_LINE(' Unsupported Version '||ora_version||' !');
    DBMS_OUTPUT.PUT_LINE('');
    END;
    set linesize 80
    set feedback on
    set serveroutput off
    Gives errors:
    END;
    ERROR at line 31:
    ORA-06550: line 31, column 7:
    PLS-00103: Encountered the symbol ";" when expecting one of the following:
    case
    ORA-06550: line 37, column 1:
    PLS-00103: Encountered the symbol "WHEN"
    ORA-06550: line 50, column 28:
    PLS-00103: Encountered the symbol ";" when expecting one of the following:
    case
    Edited by: milkyjoe on 28-Apr-2010 05:38

    Hi,
    Never write, much less post, unformatted code.
    Indent the code to show the extent of multi-line structures like BEGIN and CASE.
    For example:
    DECLARE
         /* Set supported version here */
         ora_version       VARCHAR2 (4);
         unsupp_version       EXCEPTION;
         /* Archive Log Info */
         db_log_mode      VARCHAR2 (12);
    BEGIN
         SELECT     SUBSTR(VERSION, 1, 4)
         INTO     ora_version
         FROM     v$instance;
         SELECT     log_mode
         INTO     db_log_mode
         FROM     v$database;
         CASE
             WHEN  ora_version = '10.2' THEN
              DECLARE
                  TYPE t_db IS RECORD(
                             dflsh     VARCHAR2(3),
                             dcscn      NUMBER);
                  v_db t_db;
              BEGIN
                  CASE
                      WHEN db_log_mode = 'ARCHIVELOG' THEN
                       EXECUTE IMMEDIATE 'SELECT INITCAP(flashback_on), current_scn FROM v$database'
                                           INTO v_db;
                       DBMS_OUTPUT.PUT_LINE(' Flashback On : ' || v_db.dflsh);
                       DBMS_OUTPUT.PUT_LINE(' Current SCN : ' || v_db.dcscn);
                       DBMS_OUTPUT.PUT_LINE(' Log Mode : ' || db_log_mode);
                       DBMS_OUTPUT.PUT_LINE(' Version : ' || ora_version);
                  END;
    ...The code above is what you posted, with some whitespace added.
    The error is much clearer; the last CASE statement concludes with END, but CASE blocks always have to conclude with END CASE .
    Why are you using a nested BEGIN block in the code above? Are you plannning to add an EXCEPTION handler later?
    When posting formatted text on this site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • 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

Maybe you are looking for

  • Migrate SAP from DB2 9.5 to DB2 9.7 using System copy

    Hello, We are migrating our SAP systems to new hardware and we are also planning to upgrade our database from DB2 9.5 to DB2 9.7. So my question is can we take a db backup of our current SAP system which is on DB2 9.5 and install the target SAP insta

  • Need help in installation of 10g on linux

    Hi, I am planning to install Oracle 10g on RHEL. Can anyone plss tell me if the kernel parameters are set as default or according to hardware/software specifications. What other parameters should i be careful of. I have a database of around 40GB whic

  • Adobe Acrobat Pro version 9

    I am running Windows 7 Pro with Abode Acrobat Pro version 9 with the latest update, When I right click on DOC.file I got the menu with one of the option to convert to PDF and if I select more than one file and Right click I used to get a Combine file

  • Copy and Paste Function Slow Down

    Dear Expert, Our Company have upgraded to SAP B1 2007A in April 2009, since then our users face problem in copying text in all modules.  We used to right click at a particular field, e.g. customer reference number, then right click to the paste into

  • How to transport a custom table data into QA

    Hi, Requirement is to transport data maintianed in customtable from DEV into QA. I have maintianed the delivery class to "C" in attribute and Data class to "APPL2" for this custom table. But still i am getting following error when trying to insert th