Case ...When ...In... Then

HI Guys,
Im trying to use the IN operator inside of a case statement. This what i am trying to compile in a package but get a type missmatch error.
notification - A Varchar2
case upper(notification)
when upper(notification) in ('0100', '0200') then
displayText( "Test") ;
Any Help on why i am not allowed to do this?
Any help would be really appreciated.
Thanks

Try:
create or replace procedure tst
is
notification Varchar2(100);
begin
case
when upper(notification) in ('0100', '0200') then
dbms_output.put_line( 'Test') ;
when upper(notification) in ('0300', '0400') then
dbms_output.put_line( 'Test') ;
end case;
end;
/Regards,
Miguel

Similar Messages

  • Using case when statement or decode stament in where clause

    hi gems..
    i have a problem in the following query..
    i am trying to use case when statement in the where clause of a select query.
    select cr.customer_name || ' - ' ||cr.customer_number as cust_name,
    cr.salary as salary
    from customer_details cr
    where (case when '>' = '>' then 'cr.salary > 5000'
    when '>' = '<' then 'cr.salary < 5000'
    when '>' = '=' then 'cr.salary = 5000'
    else null
    end);
    the expression in the when clause of the case-when statement will come from UI and depending on the choice i need to make the where clause.
    thats why for running the query, i have put '>' in that place.
    so the original query will look like this(for your reference):
    select cr.customer_name || ' - ' ||cr.customer_number as cust_name,
    cr.salary as salary
    from customer_details cr
    where (case when variable = '>' then 'cr.salary > 5000'
    when variable = '<' then 'cr.salary < 5000'
    when variable = '=' then 'cr.salary = 5000'
    else null
    end);
    so, in actual case,if the user selects '>' then the filter will be "where cr.salary > 5000"
    if the user selects '<' then the filter will be "where cr.salary < 5000"
    if the user selects '=' then the filter will be "where cr.salary = 5000"
    but i am getting the error "ORA 00920:invalid relational operator"
    please help..thanks in advance..

    Hi,
    select cr.customer_name || ' - ' ||cr.customer_number as cust_name,
           cr.salary                                      as salary
    from customer_details cr
    where (    v_variable = 'bigger'
           and cr.salary > 5000
       or (    v_variable = 'less'
          and cr.salary < 5000
       or (    v_variable = 'eq'
            and cr.salary = 5000
           )Edited by: user6806750 on 22.12.2011 14:56
    For some reason I can't write in sql '<', '>', '='

  • Another case when statement

    Hi, another case statement question. My set up is calling from dasnboard prompt to publisher with an rtf template. My question is whether my logic/syntax is corrected. Thank you.
    and "office"."branch" = ( CASE WHEN :BRANCH = '' THEN "office"."branch" ELSE :BRANCH END)
    case when :BRANCH is null THEN 'or' ELSE 'and' END -----> (here I want to be able either or / and in case when edit box with BRANCH parameter is null use OR operator and when BRANCH parameter is field use AND operator.
    and "office"."employee" like upper( CASE WHEN :EMPLOYEE = '' THEN "office"."employee" ELSE :EMPLOYEE END)

    try this in TOAD (replace each apostrophe of your sql by two apostrophes and add the starting and ending apostrophe to obtain a string)
    execute immediate 'INSERT INTO DATAMART.PERSONSITE (PERSON_DBID,SITE) SELECT PDBIDSKILL.DBID, MIN(PDBIDSKILL.SKILL) FROM
    (SELECT DISTINCT DATAMART.V_CFG_PERSON.DBID, CASE WHEN DATAMART.V_CFG_SKILL.NAME=''Complex_Rslve'' OR DATAMART.V_CFG_SKILL.NAME=''Broadband_Business_Resolve'' THEN ''BBHD'' WHEN DATAMART.V_CFG_SKILL.NAME=''General'' OR DATAMART.V_CFG_SKILL.NAME=''General_Mobile'' OR DATAMART.V_CFG_SKILL.NAME=''General_Billing'' THEN ''MASS'' WHEN DATAMART.V_CFG_SKILL.NAME=''Faults_General'' OR DATAMART.V_CFG_SKILL.NAME=''Faults_Business'' THEN ''Faults'' ELSE ''_Other'' END AS SKILL
    FROM DATAMART.V_CFG_SKILL INNER JOIN DATAMART.V_CFG_SKILL_LEVEL ON DATAMART.V_CFG_SKILL.DBID = DATAMART.V_CFG_SKILL_LEVEL.SKILL_DBID
    INNER JOIN DATAMART.V_CFG_PERSON ON DATAMART.V_CFG_PERSON.DBID = DATAMART.V_CFG_SKILL_LEVEL.PERSON_DBID) PDBIDSKILL GROUP BY PDBIDSKILL.DBID';it should give the same result as your original sql statement
    before using the string in VBA you must replace '' with the characters used to denote an apostrophe within apostrophes.
    I don't know nothing about VBA but I'm sure you'll know how to deal with it (an apostrophe within apostrophes).
    Regards
    Etbin

  • MIN function iside CASE WHEN

    Hi gurus,
    I am new to PL SQL and wanted to know that cant we put MIN inside the CASE WHEN.
    I have following mentioned query:
    It is not allowing me to execute it, can anyone help me out?
    SELECT A,
    B,
    D,
    E,
    F,
    SUM
    (CASE
    WHEN <Expression> THEN (CASE
    WHEN ( <Expression>
    THEN 0
    ELSE min(<Expression>) or min(<Expression>)
         END
    ELSE 0
    END
    ) AS sales
    FROM tab1
    WHERE ( column1 = 'x' )
    GROUP BY A,
    B,
    D,
    E,
    F,
    Edited by: user11001347 on Oct 29, 2009 2:34 AM

    Group functions within a case are perfectly acceptable e.g.
    select sum(case when dummy = 'X' then '1' else min(dummy) end) from dual group by dummy
    SUM(CASEWHENDUMMY='X'THEN'1'ELSEMIN(DUMMY)END)
                                                 1There are other problems with your code...
    This looks wrong to me:
    min(<Expression>) or min(<Expression>)and you have a trailing comma after F in the group by clause.
    When you're having problems with a piece of SQL, It's useful to us if you post the error you are getting back, and your table structure and sample test data too if possible.
    Edited by: Cyn on Oct 29, 2009 9:43 AM

  • Boundary on "CASE WHEN" does not what i expect

    Hi!
    The results of query1 are exactly what i expect but when i compare the counts with CASE WHEN (query2) then i get double records where the count is exactly 8. The value of Result on the second record becomes Null. This seems to me somewhat strange.
    Any suggestion?
    query1:
    SELECT DISTINCT inline_view.u_plot_number AS Research_Group,
           inline_view.external_reference AS Parental_Line,
           inline_view.u_box_code AS Box,
           inline_view.description AS Test,
           COUNT(NVL(inline_view_finalresult.u_overruled_result,inline_view_finalresult.u_calculated_result))
              OVER (PARTITION BY CONCAT(inline_view_finalresult.u_sdg_id,inline_view_finalresult.u_test_template_id)) AS R1,
           COUNT(DISTINCT NVL(inline_view_finalresult.u_overruled_result,inline_view_finalresult.u_calculated_result))
              OVER (PARTITION BY CONCAT(inline_view_finalresult.u_sdg_id,inline_view_finalresult.u_test_template_id)) AS R2
    FROM ( SELECT DISTINCT sdg.sdg_id,
                  sample.sample_id,
                  test_template.test_template_id,
                  sample_user.u_plot_number,
                  sdg.external_reference,
                  sample_user.u_box_code,
                  test.description
           FROM sdg,sdg_user,sample,sample_user,aliquot,test,test_template
           WHERE sdg.sdg_id = sdg_user.sdg_id
              AND sdg.sdg_id = sample.sdg_id
              AND sample.sample_id = sample_user.sample_id
              AND aliquot.sample_id = sample.sample_id
              AND test.aliquot_id = aliquot.aliquot_id
              AND test_template.test_template_id = test.test_template_id
              AND sdg.sdg_id >505
         ) inline_view,
         ( SELECT DISTINCT u_finalresult_user.u_sdg_id,
                  u_finalresult_user.u_calculated_result,
                  u_finalresult_user.u_overruled_result,
                  u_finalresult_user.u_sample_id,
                  u_finalresult_user.u_test_template_id
           FROM u_finalresult_user
           WHERE u_finalresult_user.u_requested = 'T'
         ) inline_view_finalresult
    WHERE inline_view.sample_id = inline_view_finalresult.u_sample_id (+)
       AND inline_view.test_template_id = inline_view_finalresult.u_test_template_id (+)
    ORDER BY inline_view.description,inline_view.u_box_codequery2:
    SELECT DISTINCT inline_view.u_plot_number AS Research_Group,
           inline_view.external_reference AS Parental_Line,
           inline_view.u_box_code AS Box,
           inline_view.description AS Test,
           CASE WHEN
                COUNT(NVL(inline_view_finalresult.u_overruled_result,inline_view_finalresult.u_calculated_result))
                OVER (PARTITION BY CONCAT(inline_view_finalresult.u_sdg_id,inline_view_finalresult.u_test_template_id)) < 8
             THEN
                'onv'
             ELSE
                CASE WHEN
                       COUNT(DISTINCT(NVL(inline_view_finalresult.u_overruled_result,inline_view_finalresult.u_calculated_result)))
                       OVER (PARTITION BY CONCAT(inline_view_finalresult.u_sdg_id,inline_view_finalresult.u_test_template_id)) > 1
                     THEN
                       'spl'
                     ELSE
                      NVL(inline_view_finalresult.u_overruled_result,inline_view_finalresult.u_calculated_result)
                END
          END AS Result
    FROM ( SELECT DISTINCT sdg.sdg_id,
                  sample.sample_id,
                  test_template.test_template_id,
                  sample_user.u_plot_number,
                  sdg.external_reference,
                  sample_user.u_box_code,
                  test.description
           FROM sdg,sdg_user,sample,sample_user,aliquot,test,test_template
           WHERE sdg.sdg_id = sdg_user.sdg_id
              AND sdg.sdg_id = sample.sdg_id
              AND sample.sample_id = sample_user.sample_id
              AND aliquot.sample_id = sample.sample_id
              AND test.aliquot_id = aliquot.aliquot_id
              AND test_template.test_template_id = test.test_template_id
              AND sdg.sdg_id >505
         ) inline_view,
         ( SELECT DISTINCT u_finalresult_user.u_sdg_id,
                  u_finalresult_user.u_calculated_result,
                  u_finalresult_user.u_overruled_result,
                  u_finalresult_user.u_sample_id,
                  u_finalresult_user.u_test_template_id
           FROM u_finalresult_user
           WHERE u_finalresult_user.u_requested = 'T'
         ) inline_view_finalresult
    WHERE inline_view.sample_id = inline_view_finalresult.u_sample_id (+)
       AND inline_view.test_template_id = inline_view_finalresult.u_test_template_id (+)
    ORDER BY inline_view.description,inline_view.u_box_code

    NVL(inline_view_finalresult.u_overruled_result,inline_view_finalresult.u_calculated_result)does not return double records without the CASE WHEN (see below) but i don't understand why it comes that when i compares the counts in a CASE WHEN that i get double records where the second record has value Null as Result. Could somebody provide me with a solution?
    SELECT DISTINCT inline_view.u_plot_number AS Research_Group,
           inline_view.external_reference AS Parental_Line,
           inline_view.u_box_code AS Box,
           inline_view.description AS Test,
           COUNT(NVL(inline_view_finalresult.u_overruled_result,inline_view_finalresult.u_calculated_result))
              OVER (PARTITION BY CONCAT(inline_view_finalresult.u_sdg_id,inline_view_finalresult.u_test_template_id)) AS R1,
           COUNT(DISTINCT NVL(inline_view_finalresult.u_overruled_result,inline_view_finalresult.u_calculated_result))
              OVER (PARTITION BY CONCAT(inline_view_finalresult.u_sdg_id,inline_view_finalresult.u_test_template_id)) AS R2,
    NVL(inline_view_finalresult.u_overruled_result,inline_view_finalresult.u_calculated_result) AS Result
    FROM ( SELECT DISTINCT sdg.sdg_id,
                  sample.sample_id,
                  test_template.test_template_id,
                  sample_user.u_plot_number,
                  sdg.external_reference,
                  sample_user.u_box_code,
                  test.description
           FROM sdg,sdg_user,sample,sample_user,aliquot,test,test_template
           WHERE sdg.sdg_id = sdg_user.sdg_id
              AND sdg.sdg_id = sample.sdg_id
              AND sample.sample_id = sample_user.sample_id
              AND aliquot.sample_id = sample.sample_id
              AND test.aliquot_id = aliquot.aliquot_id
              AND test_template.test_template_id = test.test_template_id
              AND sdg.sdg_id >505
         ) inline_view,
         ( SELECT DISTINCT u_finalresult_user.u_sdg_id,
                  u_finalresult_user.u_calculated_result,
                  u_finalresult_user.u_overruled_result,
                  u_finalresult_user.u_sample_id,
                  u_finalresult_user.u_test_template_id
           FROM u_finalresult_user
           WHERE u_finalresult_user.u_requested = 'T'
         ) inline_view_finalresult
    WHERE inline_view.sample_id = inline_view_finalresult.u_sample_id (+)
       AND inline_view.test_template_id = inline_view_finalresult.u_test_template_id (+)
    ORDER BY inline_view.description,inline_view.u_box_code

  • Using CASE WHEN THEN in dynamic Region Source area

    Hi all,
    I've been knocking my head around on this one for a while. Hope someone can show me some guidance. So far, the SQL Query in the Region Source works ok except after the THEN ''||'LINK'||'' . All text between the single quotes displays, and not just the hyperlink LINK. (My goal is to this simple test working, then go back an substitute in APP_ID, Page#, SESSION variables.) But I'm stuck with this problem. Searched the forum but this is as far as I got. Below is the code I'm using in the Region Source area. Perhaps a region attribute setting is needed but I'm unsure. Thanks for any assistance. -Mike
    select DISTINCT
        AWARD,
        CASE
        WHEN WINNER_NAME = 'India Retail Support Team'
       THEN '<A HREF="http://www.hotmail.com">'||'LINK'||'</A>'         *----------------HREF link (LINK) is working fine here but doesn't work ok in Region Source.
        ELSE WINNER_NAME
        END WN,
            GBU_WINNER,
            DORDER
    from   GBUSERVICEPACESETTERAWARDS
    where FY = '2012'
    and TYPE = 'Service Award'

    >
    As previously requested, please update your forum profile with a real handle instead of "user10734329".
    I've been knocking my head around on this one for a while. Hope someone can show me some guidance. So far, the SQL Query in the Region Source works ok except after the THEN ''||'LINK'||'' . All text between the single quotes displays, and not just the hyperlink LINK.Not clear from this what the problem is. It appears to me that LINK is all of the "text between the single quotes". What do you mean by "all text"? (An example on apex.oracle.com is a good way to resolve such ambiguities...)
    The usual cause of unexpected results when the separation of concerns is breached and HTML is directly generated in report queries is having the Display Text As report column attribute wrongly set. Ensure it is Standard Report Column rather than the default Display as Text (escape special characters).

  • CASE WHEN statement IS NULL THEN  ......

    -- i've table's acoount and owner
    create table account
    ( code-number(30) , name-nvarchar(200)) 
    create table owner
    ( code-nvarchar2(20 BYTE) ,
    name -nvarchar(100),
    account_code-number(30))  account_code is foreign key
    code
    name
    account_code
    1.1
    a
    1.1
    5
    x
    5
    3.3
    c
    3.3
    7
    y
    19
    dd
    code
    name
    1.1
    z
    5
    b
    3.3
    c
    3.3
    c
    now my result should be
    code(owner)
    name(owner)
    code(account)
    name(account)
    1.1
    a
    1.1
    z
    5
    x
    5.
    b
    3.3
    c
    3.3
    c
    7
    y
    19
    dd
    my script
    SELECT CASE WHEN O.ACCOUNT_CODE IS NULL THEN A.CODE=NULL  ELSE A.CODE=(VALUE) END,  // HOW SHOULD I WRTIE HERE ???
                 CASE WHEN O.ACCOUNT_CODE IS NULL THEN  A.NAME=NULL  ELSE A.NAME=(VALUE) END,
             O.CODE,
             O.NAME
        FROM OWNER  O,
                  ACCOUNT  A
       WHERE     A.CODE = O.ACCOUNT_CODE;

    I don't see the need for case statement here. Cant you just do this.
    SQL> with owner
      2  as
      3  (
      4  select 1.1 code, 'a ' name, 1.1  account_code from dual union all
      5  select 5   code, 'x ' name, 5    account_code from dual union all
      6  select 3.3 code, 'c ' name, 3.3  account_code from dual union all
      7  select 7   code, 'y ' name, null account_code from dual union all
      8  select 19  code, 'dd' name, null account_code from dual
      9  ), account
    10  as
    11  (
    12  select 1.1 code, 'z' name from dual union all
    13  select 5   code, 'b' name from dual union all
    14  select 3.3 code, 'c' name from dual union all
    15  select 3.3 code, 'c' name from dual
    16  )
    17  select o.code "code (owner)"
    18       , o.name "name (owner)"
    19       , a.code "code (account)"
    20       , a.name "name (account)"
    21    from owner o
    22    left
    23    join (
    24           select distinct code, name
    25             from account
    26         ) a
    27      on o.account_code = a.code
    28   order
    29      by 1;
    code (owner) name (owner)    code (account) name (account)
             1.1 a                          1.1 z
             3.3 c                          3.3 c
               5 x                            5 b
               7 y
              19 dd

  • CASE WHEN THEN END

    Hello everyone,
    We have a function return Y or N.
    We have 2 table YTable YT and NTable NT.
    We are using UNION now.
    SELECT ONE.CL1
    FROM (
    SELECT CL1Y FROM YTable WHERE FUNCTION = 'Y'
    UNION
    SELECT CL1N FROM NTable WHERE FUNCTION = 'N') ONEWe are wondering to use CASE, WHEN, THEN, END.
    Is it possible or NOT?
    If you have a chance, please share your experiences.
    Thanks in advance,
    NY
    P.S.
    If you have more questions, please let us know.
    Edited by: New Yorker on Aug 31, 2010 10:08 AM

    New Yorker,
    According to the given SQL block, the case function can not be used. You can use the case function with multiple table joins but you can only use the CASE WHEN ELSE END block for one column.
    If i got your question correct, that is my answer to your question.
    Regards.
    Ogan

  • Case when then not working

    In my database, two variable ID and time (varchar2) are there. I want to populate another variable using case when then by putting below conditon to convert like this
    But its not working. Can anyone help me
    if time =1 day then '1 Day'
    time > 2 days and time <=7 days then '2 to 7 days'
    time > 8 days and time <=15 days then '8 to 15 days'
    else 'not matching'
    ID Time
    12 1 days
    23 244 days
    12 2 days
    14 4 days
    15 6 days
    17 9 days
    select time,
    case WHEN
    UPPER(Time) = '1 DAY'
    THEN
    '1 day'
    WHEN
    UPPER(Time) Between '2 DAYS' and '7 DAYS'
    THEN
    '2 to 7 days'
    WHEN
    UPPER(Time) Between '8 DAYS' and '15 DAYS'
    THEN
    '8 to 15 days'
    ELSE
    'Not matching'
    END "update time"
    from table1

    900487 wrote:
    In my database, two variable ID and time (varchar2) are there. If you are storing Days in a column store it as NUMBER or INTERVAL data type. The way you have stored the value looks incorrect.
    What you can do is extract the number portion of your time column and apply the CASE statement. Something like this
    SQL> with t
      2  as
      3  (
      4  select 12 id, '1 days' time1 from dual union all
      5  select 23 id, '244 days' time1 from dual union all
      6  select 12 id, '2 days' time1 from dual union all
      7  select 14 id, '4 days' time1 from dual union all
      8  select 15 id, '6 days' time1 from dual union all
      9  select 17 id, '9 days' time1 from dual
    10  )
    11   select id,
    12          time1,
    13          case when time1 = 1              then '1 day'
    14               when time1 between 2 and 7  then '2 to 7 days'
    15               when time1 between 8 and 15 then '8 to 15 days'
    16               else 'not matching'
    17          end "update time"
    18     from (
    19              select id, to_number(regexp_substr(time1, '^[[:digit:]]*')) time1
    20                from t
    21          )
    22  /
            ID      TIME1 update time
            12          1 1 day
            23        244 not matching
            12          2 2 to 7 days
            14          4 2 to 7 days
            15          6 2 to 7 days
            17          9 8 to 15 days
    6 rows selected.

  • CASE..WHEN &a THEN decode(instr(colA,'-') 1,colA,......

    Using CASE within a function I wish to apply a second level of criteria within the CASE statement, something along the lines of the following:
    CASE upper(option_in)
    WHEN 'P' THEN decode(instr(value_in,'-')>1,value_in,plan_b)
    WHEN ...
    Looks nifty but doesn't work. Any suggestions would be appreciated.
    Thanks,
    Dan

    Why are you switching to DECODE? Just use CASE again:
    case upper(option_in)
    when 'P' then case
                  when instr(value_in, '-') > 1 then value_in
                  else plan_b
                  end
    when ...

  • Case-when-then logic in join condition

    Is it possible to implement case when then logic in join condition?
    Instead of:
    INGRP1.COL1 = INGRP2.COL1 (+)
    something like:
    case
    when INGRP1.COL2 IS NULL
    then INGRP1.COL1 = INGRP2.COL1 (+)
    else INGRP1.COL3 = INGRP2.COL3 (+)
    end
    expression builder for join condition.
    Any help much appreciated.

    Hi Kaiser,
    this is my variant
    1) join first table with second table twice (define two input group in join, include second table in mapping twice and map them to appropriate join group)
    INGRP1.COL1=INGRP2.COL1(+) and INGRP1.COL3=INGRP3.COL3(+)
    2) after join calculate attributes from second table with expression like
    case when COL2 IS NULL the INGRP2_ATTR else INGRP3_ATTR end
    Maybe anyone has a better solution...
    Regards,
    Oleg

  • 'max case when...then' does it work in Desktop reports as a calculation?

    Hi!
    I've used 'max case when...then' in my SQL in Admin edition. It works fine. However when I try to use it as a part of my calculation:
    MAX(CASE
    WHEN (:Payroll Month 1 - Gross Sal)
    THEN TO_NUMBER(NVL("Gross Salary ".Basic Salary, 0)) Else 0 END)
    in this manner, it gives me the error message that
    'Error in formula - Unexpected end of formula - syntax error : Token THEN at position 52'
    Can someone guide me please?
    Thanks and regards,
    Aparna

    Aparna.
    You cannot - without some function coding - pass Discoverer run time parameters to the Admin edition (ie: to a folder, SQL view, etc.).
    If you're tyring to write a calculation like you describe, can't this just be in the Plus or Desktop version and not Admin?
    So, it's a calculation in the report and not the EUL?
    Russ

  • "CASE WHEN 1=0 THEN.......ELSE....END"??

    This might be very basic question still I'm confused about it.
    Can you please explain me "CASE WHEN 1=0 THEN.......ELSE....END"?
    Where and why to use this statement??
    Help appreciated.

    First let's break down what it means. Since 1 is never equal to 0, OBI will ignore what comes immediately after and execute what comes after the ELSE.
    So why would we want to do this? Well, often we want to perform some action that has nothing to do with a particular column in our subject area. By using this CASE statement, we trick OBI into thinking we are using a column for a calculation or action, but in effect, the column is unchanged.
    For example, suppose you were building a dashboard prompt. You want to use a column twice in your dashboard prompt, say an ACCOUNT_OPEN_DATE column to get a range of dates. You cannot use the same column twice in a dashboard prompt. (Try it, OBI will ignore your attempt to put the same column twice into your workspace.)
    So what do you do? First you get a column (in this example, I'm using a CHAR column) like Branch Name. It doesn't matter what column you use. The CHAR is used so the syntax makes sense.
    You move the column to your workspace. Now you click on the Edit Formula and you type CASE WHEN 1=0 THEN Organization."Branch Name" ELSE 'TEST' END.
    So in this case, the values of Branch Name are unaffected and the dummy column just represents the word 'TEST.' Now in the "Show" part of the prompt, we switch to "SQL Results" and type SELECT "Account Attributes".Account_Open_Date FROM Subject Area and set this to a PV called StartDate.
    Because the column is a dummy, you can actually call it again. Use the same CASE statement to make it a "dummy" column. Then use the same SQL you used above, but this time save it to a PV called EndDate.
    Now you have two date values you can use on your ACCOUNT_OPEN_DATE column to get a range of dates.
    So, in conclusion, normally you choose a column from your subject area, because you need the values of that column in your report. But when you just need a column to do something unrelated to any column, you use the CASE 1=0 to make it a "dummy" column and then you can perform your action.
    HTH,

  • "case when not m[1] is present then" outputs ORA-03113

    I find that "case when not m[1] is present then" outputs ORA-03113:
    Why?
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    select * from dual model
    dimension by(0 as d)
    measures(1 as m)
    rules(
    m[any] = case when not m[1] is present then 1 end);
    ORA-03113:Below one is alterNative solution.
    select * from dual model
    dimension by(0 as d)
    measures(1 as m)
    rules(
    m[any] = case when presentv(m[1],1,0) = 0 then 3 end);
    D  M
    0  3

    I get:
    ops$me%DB>  select * from dual model
      2    dimension by(0 as d)
      3    measures(1 as m)
      4    rules(
      5    m[any] = case when not m[1] is present then 1 end);
    select * from dual model
    ERROR at line 1:
    ORA-03002: operator not implemented
    Elapsed: 00:00:00.03
    ops$me%DB> select banner from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for IBM/AIX RISC System/6000: Version 10.2.0.4.0 - Productio
    NLSRTL Version 10.2.0.4.0 - Production

  • My nested CASE WHEN THEN ELSE is not working.

    I'm working on a report that will provide a status on a component based on a defined Matrix.  The status to report is determined in a hierarchal fashion...the highest seqence number status existing is reported. 
    I've capped the sequence number at 10 (@SeqNumCap_sav)
    The matrix table is defined as such:
    CREATE TABLE [dbo].[tblAssyLineComponentStatusMatrix](
    [MatrixAssyLine] [char](1) NOT NULL,
    [MatrixComponentProduct] [char](15) NOT NULL,
    [MatrixComponentStatusSequence] [decimal](3, 0) NOT NULL,
    [MatrixComponentStatus] [char](3) NOT NULL,
    [MatrixStatusDescription] [nvarchar](100) NOT NULL,
    [MatrixReportedDescription1] [nvarchar](50) NOT NULL,
    [MatrixReportedDescription2] [nvarchar](50) NULL,
    [MatrixReportedDescription3] [nvarchar](50) NULL,
    [MatrixReportedDescription4] [nvarchar](50) NULL,
    [MatrixReportedDescription5] [nvarchar](50) NULL
    ) ON [PRIMARY]
    This is a sample of the tblAssyLineComponentStatusMatrix data:
    MatrixAssyLine MatrixComponentProduct MatrixComponentStatusSequence MatrixComponentStatus MatrixStatusDescription MatrixReportedDescription1 MatrixReportedDescription2 MatrixReportedDescription3 MatrixReportedDescription4 MatrixReportedDescription5
    E Mast/PullRod    1 W   The part has been stamped or welded. Class3PullRods NULL NULL NULL NULL
    E Mast/PullRod    2 P   The part has been clicked off in a paint hang station. TSMastPaintHang NULL NULL NULL NULL
    E Mast/PullRod    3 Y   The part has been clicked off in paint pulldown. TSMastPaintUnload NULL NULL NULL NULL
    the tblProductionControlComponentReporting is defined as:
    CREATE TABLE [dbo].[tblProductionControlComponentReporting](
    [WorkUnit] [nvarchar](15) NOT NULL,
    [Description] [nvarchar](50) NOT NULL,
    [Completed] [datetime] NOT NULL,
    [UserID] [nvarchar](30) NULL,
    [StationID] [nvarchar](30) NULL,
    [Undo] [bit] NULL,
    [CompletedUndo] [datetime] NULL,
    [UserIDUndo] [nvarchar](30) NULL,
    [StationIDUndo] [nvarchar](30) NULL,
    [ComponentPartNo] [varchar](15) NULL,
    [ComponentClass] [varchar](3) NULL,
    [ComponentQty] [decimal](6, 2) NULL,
    [ComponentScheduleDate] [datetime] NULL,
    [ComponentScheduleShift] [decimal](1, 0) NULL,
    [ComponentScheduleWorkunitSequence] [int] NULL,
    [ComponentComment] [varchar](200) NULL
    ) ON [PRIMARY]
    A sample of the tblProductionControlComponentreporting data:
    assyline WorkUnit Description Completed UserID StationID
    E 639422 Class3PullRods 2014-09-15 13:15:44.607 GLOBAL\agmesusr ag2100156
    E 639422 Class3PullRods 2014-09-15 13:15:44.607 GLOBAL\agmesusr ag2100156
    E 639422          TSFrameFabDeliver 2014-09-25 11:31:44.380 NULL MCA
    E 639422 TSMastPaintHang 2014-09-25 22:56:43.740 009932 AG2100294
    The problem is that the below code is returning multple records which is causing an error ... if I resequence the above Matrix table data where #3 becomes #10, 2 becomes #9 and 1 becomes #8, the query works fine - but this approach doesn't allow for easy
    expansion of the data.  Can anyone help me see the problem here?
    use eschedule
    declare @Workunit varchar(max)
    declare @SeqNumCap_sav dec(3, 0)
    set @WorkUnit='639422'
    set @SeqNumCap_sav= (select top 1 SequenceValueCap from tblAssyLineComponentStatusMatrix_SequenceCap order by SequenceValueCap)
    select
    Mast_PullRodStatus = case
    --Seq 10 Mast/PullRod Component Status
    when (select top 1 [description] from tblproductioncontrolcomponentreporting
    where ([description] = (select MatrixReportedDescription1 from tblAssyLineComponentStatusMatrix where MatrixComponentProduct='Mast/PullRod' and MatrixComponentStatusSequence=@SeqNumCap_sav and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit))))
    and Workunit=@WorkUnit
    ) is not null
    then
    (select MatrixComponentStatus from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=@SeqNumCap_sav
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit)))
    --Seq 9 Mast/PullRod Component Status
    else case
    when (select top 1 [description] from tblproductioncontrolcomponentreporting
    where ([description] = (select MatrixReportedDescription1 from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-1)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit))))
    and Workunit=@WorkUnit
    ) is not null
    then (select MatrixComponentStatus from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-1)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit)))
    --Seq 8 Mast/PullRod Component Status
    else case
    when (select top 1 [description] from tblproductioncontrolcomponentreporting
    where ([description] = (select MatrixReportedDescription1 from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-2)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit))))
    and Workunit=@WorkUnit
    ) is not null
    then (select MatrixComponentStatus from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-2)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit)))
    --Seq 7 Mast/PullRod Component Status
    else case
    when (select top 1 [description] from tblproductioncontrolcomponentreporting
    where ([description] = (select MatrixReportedDescription1 from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-3)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit))))
    and Workunit=@WorkUnit
    ) is not null
    then (select MatrixComponentStatus from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-3)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit)))
    --Seq 6 Mast/PullRod Component Status
    else case
    when (select top 1 [description] from tblproductioncontrolcomponentreporting
    where ([description] = (select MatrixReportedDescription1 from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-4)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit))))
    and Workunit=@WorkUnit
    ) is not null
    then (select MatrixComponentStatus from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-4)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit)))
    --Seq 5 Mast/PullRod Component Status
    else case
    when (select top 1 [description] from tblproductioncontrolcomponentreporting
    where ([description] = (select MatrixReportedDescription1 from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-5)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit))))
    and Workunit=@WorkUnit
    ) is not null
    then (select MatrixComponentStatus from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-5)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit)))
    --Seq 4 Mast/PullRod Component Status
    else case
    when (select top 1 [description] from tblproductioncontrolcomponentreporting
    where ([description] = (select MatrixReportedDescription1 from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-6)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit))))
    and Workunit=@WorkUnit
    ) is not null
    then (select MatrixComponentStatus from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-6)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit)))
    --Seq 3 Mast/PullRod Component Status
    else case
    when (select top 1 [description] from tblproductioncontrolcomponentreporting
    where ([description] = (select MatrixReportedDescription1 from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-7)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit))))
    and Workunit=@WorkUnit
    ) is not null
    then (select MatrixComponentStatus from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-7)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit)))
    --Seq 2 Mast/PullRod Component Status
    else case
    when (select top 1 [description] from tblproductioncontrolcomponentreporting
    where ([description] = (select MatrixReportedDescription1 from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-8)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit))))
    and Workunit=@WorkUnit
    ) is not null
    then (select MatrixComponentStatus from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod' and MatrixComponentStatusSequence=(@SeqNumCap_sav-8))
    --Seq 1 Mast/PullRod Component Status
    else case
    when (select top 1 [description] from tblproductioncontrolcomponentreporting
    where ([description] = (select MatrixReportedDescription1 from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-9)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit))))
    and Workunit=@WorkUnit
    --and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit))
    ) is not null
    then (select MatrixComponentStatus from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-9)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit)))
    else ' '
    end
    end
    end
    end
    end
    end
    end
    end
    end
    end
    Assume Assyline='E'
    Eva Leggett

    Good job posting the DDL.
    Your example data should be in a table format though.
    DECLARE @tblAssyLineComponentStatusMatrix TABLE (MatrixAssyLine char(1) NOT NULL, MatrixComponentProduct char(15) NOT NULL, MatrixComponentStatusSequence decimal(3, 0) NOT NULL, MatrixComponentStatus char(3) NOT NULL, MatrixStatusDescription nvarchar(100) NOT NULL, MatrixReportedDescription1 nvarchar(50) NOT NULL, MatrixReportedDescription2 nvarchar(50) NULL, MatrixReportedDescription3 nvarchar(50) NULL, MatrixReportedDescription4 nvarchar(50) NULL, MatrixReportedDescription5 nvarchar(50) NULL)
    INSERT INTO @tblAssyLineComponentStatusMatrix (MatrixAssyLine, MatrixComponentProduct, MatrixComponentStatusSequence, MatrixComponentStatus, MatrixStatusDescription, MatrixReportedDescription1, MatrixReportedDescription2, MatrixReportedDescription3, MatrixReportedDescription4, MatrixReportedDescription5) VALUES ('E' ,'Mast/PullRod' ,1 ,'W' ,'The part has been stamped or welded. ','Class3PullRods ' ,NULL, NULL, NULL, NULL)
    INSERT INTO @tblAssyLineComponentStatusMatrix (MatrixAssyLine, MatrixComponentProduct, MatrixComponentStatusSequence, MatrixComponentStatus, MatrixStatusDescription, MatrixReportedDescription1, MatrixReportedDescription2, MatrixReportedDescription3, MatrixReportedDescription4, MatrixReportedDescription5) VALUES ('E' ,'Mast/PullRod' ,2 ,'P' ,'The part has been clicked off in a paint hang station. ','TSMastPaintHang ' ,NULL, NULL, NULL, NULL)
    INSERT INTO @tblAssyLineComponentStatusMatrix (MatrixAssyLine, MatrixComponentProduct, MatrixComponentStatusSequence, MatrixComponentStatus, MatrixStatusDescription, MatrixReportedDescription1, MatrixReportedDescription2, MatrixReportedDescription3, MatrixReportedDescription4, MatrixReportedDescription5) VALUES ('E' ,'Mast/PullRod' ,3 ,'Y' ,'The part has been clicked off in paint pulldown. ','TSMastPaintUnload ' ,NULL, NULL, NULL, NULL)
    DECLARE @tblProductionControlComponentReporting TABLE (WorkUnit nvarchar(15) NOT NULL, Description nvarchar(50) NOT NULL, Completed datetime NOT NULL, UserID nvarchar(30) NULL, StationID nvarchar(30) NULL, Undo bit NULL, CompletedUndo datetime NULL, UserIDUndo nvarchar(30) NULL, StationIDUndo nvarchar(30) NULL, ComponentPartNo varchar(15) NULL, ComponentClass varchar(3) NULL, ComponentQty decimal(6, 2) NULL, ComponentScheduleDate datetime NULL, ComponentScheduleShift decimal(1, 0) NULL, ComponentScheduleWorkunitSequence int NULL, ComponentComment varchar(200) NULL)
    INSERT INTO @tblProductionCOntrolComponentReporting (WorkUnit, Description, Completed, UserID, StationID) VALUES (639422, 'Class3PullRods', '2014-09-15 13:15:44.607', 'GLOBAL\agmesusr', 'ag2100156')
    INSERT INTO @tblProductionCOntrolComponentReporting (WorkUnit, Description, Completed, UserID, StationID) VALUES (639422, 'Class3PullRods', '2014-09-15 13:15:44.607', 'GLOBAL\agmesusr', 'ag2100156')
    INSERT INTO @tblProductionCOntrolComponentReporting (WorkUnit, Description, Completed, UserID, StationID) VALUES (639422, 'TSFrameFabDeliver', '2014-09-25 11:31:44.380', NULL, 'MCA')
    INSERT INTO @tblProductionCOntrolComponentReporting (WorkUnit, Description, Completed, UserID, StationID) VALUES (639422, 'TSMastPaintHang', '2014-09-25 22:56:43.740', '009932', 'AG2100294')
    Your code is a mess, it would take longer to untangle it that it would to solve your problem.
    Can you give us an expected output, and perhaps the rules governing what your case statement should be doing?

  • Using case when statement in the select query to create physical table

    Hello,
    I have a requirement where in I have to execute a case when statement with a session variable while creating a physical table using a select query. let me explain with an example.
    I have a physical table based on a select table with one column.
    SELECT 'VALUEOF(NQ_SESSION.NAME_PARAMETER)' AS NAME_PARAMETER FROM DUAL. Let me call this table as the NAME_PARAMETER table.
    I also have a customer table.
    In my dashboard that has two pages, Page 1 contains a table with the customer table with column navigation to my second dashboard page.
    In my second dashboard page I created a dashboard report based on NAME_PARAMETER table and a prompt based on customer table that sets the NAME_ PARAMETER request variable.
    EXECUTION
    When i click on a particular customer, the prompt sets the variable NAME_PARAMETER and the NAME_PARAMETER table shows the appropriate customer.
    everything works as expected. YE!!
    Now i created another table called NAME_PARAMETER1 with a little modification to the earlier table. the query is as follows.
    SELECT CASE WHEN 'VALUEOF(NQ_SESSION.NAME_PARAMETER)'='Customer 1' THEN 'TEST_MART1' ELSE TEST_MART2' END AS NAME_PARAMETER
    FROM DUAL
    Now I pull in this table into the second dashboard page along with the NAME_PARAMETER table report.
    surprisingly, NAME_PARAMETER table report executes as is, but the other report based on the NAME_PARAMETER1 table fails with the following error.
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 16001] ODBC error state: S1000 code: 1756 message: [Oracle][ODBC][Ora]ORA-01756: quoted string not properly terminated. [nQSError: 16014] SQL statement preparation failed. (HY000)
    SQL Issued: SET VARIABLE NAME_PARAMETER='Novartis';SELECT NAME_PARAMETER.NAME_PARAMETER saw_0 FROM POC_ONE_DOT_TWO ORDER BY saw_0
    If anyone has any explanation to this error and how we can achieve the same, please help.
    Thanks.

    Hello,
    Updates :) sorry.. the error was a stupid one.. I resolved and I got stuck at my next step.
    I am creating a physical table using a select query. But I am trying to obtain the name of the table dynamically.
    Here is what I am trying to do. the select query of the physical table is as follows.
    SELECT CUSTOMER_ID AS CUSTOMER_ID, CUSTOMER_NAME AS CUSTOMER_NAME FROM 'VALUEOF(NQ_SESSION.SCHEMA_NAME)'.CUSTOMER.
    The idea behind this is to obtain the data from the same table from different schemas dynamically based on what a session variable. Please let me know if there is a way to achieve this, if not please let me know if this can be achieved in any other method in OBIEE.
    Thanks.

Maybe you are looking for

  • Imac will not reboot in safe mode

    Attempted to restart imac (10.8.4) by holding down shift key, went through progress bar, and now still apple logo with pinwheel - any suggestions? I have unplugged the externals with time machine and the other external.

  • HT2534 why isn't there 'None' in the payment method in my iphone? I could not skip it. Please help

    why isn't there 'None' in the payment method in my iphone? I could not skip the billing info. Please help

  • Screen saver broken

    I set the screen saver to the iTunes artwork one, set it to change a picture every .5 seconds, and set it to 2 rows. It immediately crashed and since then, I cannot access the screen saver settings in System Preferences and whenever it goes to screen

  • Drop down function no longer works in firefox 19

    Firefox 19 installed. have uninstalled and reinstalled twice, have followed the trouble shooting suggestions and have had my IT department try and resolve this issue without success. If I type in an area that normally auto populates, with for example

  • Cannot allocate new log importing hanging

    Hai All, When I imort a 1.59 Gb data into a database after some time a mesaage in alertlog file and import hanging message ====== Thread 1 cannot allocate new log, sequence 7 Checkpoint not complete ====== I have 3 redo log groups with 2 members with