Subqueries and Case

I have two codes - A & B
My question is can I use code B i.e Case statement as a subquery of code A to get the necessary output
=============================CODE A=====================================================
select a.search_code,a.name,a.total as "Total Service Calls",decode(b.total_adjusted_miss,null,0,b.total_adjusted_miss) "Missed SLA (Adjusted)",
decode(c.total_unadjusted_miss,null,0,c.total_unadjusted_miss) "Missed SLA (UnAdjusted)",
decode(round(((a.total - b.total_adjusted_miss)/a.total)*100,2),null,100,round(((a.total - b.total_adjusted_miss)/a.total)*100,2)) "Total Adjusted Yield %",
decode(round(((a.total - c.total_unadjusted_miss)/a.total)*100,2),null,100,round(((a.total - c.total_unadjusted_miss)/a.total)*100,2)) "Total UnAdjusted Yield %"
from (
(SELECT
count(*) as total,
sg.search_code,
sg.NAME
FROM
task t,
operational_process op,
support_group sg,
person p
where sg.support_group_seq_id in (SELECT sg2.support_group_seq_id FROM support_group sg2
start with sg2.SEARCH_CODE = p_target_name
connect by prior sg2.support_group_seq_id=sg2.parent_support_group_seq_id)
and t.task_seq_id = op.task_seq_id
and t.task_seq_id = op.task_seq_id
and sg.support_group_seq_id = op.support_group_seq_id
and op.assigned_person_seq_id = p.person_seq_id
and sg.search_code = p_target_name
and t.task_type in ('Inc')
and to_char(op.est_actual_end_datetime, 'MM-YYYY') = '02-2012'
and t.priority is not null
group by sg.search_code, sg.name
))a,
=============================CODE B=====================================================
Select t.task_number, CASE
WHEN ((T.PRIORITY like ('%Immediate%')) AND
(OP._ACTUAL_END_DATETIME - OP._ACTUAL_START_DATETIME) * 24 < 2) THEN
1
WHEN ((T.PRIORITY like ('%Critical%')) AND
(OP._ACTUAL_END_DATETIME - OP._ACTUAL_START_DATETIME) * 24 < 4) THEN
1
WHEN ((T.PRIORITY like ('%Urgent%')) AND
OP.ACTUAL_DUR_HOURS_DECIMAL <= 24) THEN
1
WHEN ((OP.PRIORITY like ('%Medium%')) AND
OP.ACTUAL_DUR_HOURS_DECIMAL <= 120) THEN
1
WHEN ((T.PRIORITY like ('%Normal%')) AND
OP.ACTUAL_DUR_HOURS_DECIMAL <= 72) THEN
1
ELSE
0
END W2W_SLA,
CASE
WHEN ((T.PRIORITY like ('%Immediate%')) AND
((OP._ACTUAL_END_DATETIME - OP._ACTUAL_START_DATETIME) * 24) -
NVL(OP.EXCEPTION_DUR_HOURS_DEC, 0) <= 2) THEN
1
WHEN ((T.PRIORITY like ('%Critical%')) AND
((OP._ACTUAL_END_DATETIME - OP._ACTUAL_START_DATETIME) * 24) -
NVL(OP.EXCEPTION_DUR_HOURS_DEC, 0) <= 4) THEN
1
WHEN ((T.PRIORITY like ('%Urgent%')) AND
OP.ACTUAL_DUR_HOURS_DECIMAL -
NVL(OP.EXCEPTION_DUR_HOURS_DEC, 0) <= 24) THEN
1
WHEN ((T.PRIORITY like ('%Medium%')) AND
OP.ACTUAL_DUR_HOURS_DECIMAL -
NVL(OP.EXCEPTION_DUR_HOURS_DEC, 0) <= 120) THEN
1
WHEN ((T.PRIORITY like ('%Normal%')) AND
OP.ACTUAL_DUR_HOURS_DECIMAL -
NVL(OP.EXCEPTION_DUR_HOURS_DEC, 0) <= 72) THEN
1
ELSE
0
END W2W_SLA_EXCEPTION
from task t, operationalprocess OP, support_group s
where t.task_seq_id = op.task_seq_id
and t.task_type in ('Inc', 'SR')
and op.support_group_seq_id = s.support_group_seq_id
--and s.name = 'L3 Service Management Data Warehouse Development'
and to_char(t._actual_end_datetime, 'MM-YYYY') = '02-2012'

Hello
I'm not quite clear on what you're asking. You want to know if it's possible to put query A in a subquery so you can access the columns to use in query b?
If so, a subquery wouldn't be a particularly efficient way of doing it as you would need to repeat it for each attribute. Instead you could use an inline view something like so (bear in mind I don't have your tables or data so I can't test whether this even runs!)
SELECT t.task_number,
      CASE
          WHEN ((t.priority LIKE ('%Immediate%')) AND
               (op._actual_end_datetime - op._actual_start_datetime) * 24 < 2) THEN
           1
          WHEN ((t.priority LIKE ('%Critical%')) AND
               (op._actual_end_datetime - op._actual_start_datetime) * 24 < 4) THEN
           1
          WHEN ((t.priority LIKE ('%Urgent%')) AND op.actual_dur_hours_decimal <= 24) THEN
           1
          WHEN ((op.priority LIKE ('%Medium%')) AND op.actual_dur_hours_decimal <= 120) THEN
           1
          WHEN ((t.priority LIKE ('%Normal%')) AND op.actual_dur_hours_decimal <= 72) THEN
           1
          ELSE
           0
      END w2w_sla,
      CASE
          WHEN ((t.priority LIKE ('%Immediate%')) AND ((op._actual_end_datetime - op._actual_start_datetime) * 24) -
               nvl(op.exception_dur_hours_dec, 0) <= 2) THEN
           1
          WHEN ((t.priority LIKE ('%Critical%')) AND ((op._actual_end_datetime - op._actual_start_datetime) * 24) -
               nvl(op.exception_dur_hours_dec, 0) <= 4) THEN
           1
          WHEN ((t.priority LIKE ('%Urgent%')) AND
               op.actual_dur_hours_decimal - nvl(op.exception_dur_hours_dec, 0) <= 24) THEN
           1
          WHEN ((t.priority LIKE ('%Medium%')) AND
               op.actual_dur_hours_decimal - nvl(op.exception_dur_hours_dec, 0) <= 120) THEN
           1
          WHEN ((t.priority LIKE ('%Normal%')) AND
               op.actual_dur_hours_decimal - nvl(op.exception_dur_hours_dec, 0) <= 72) THEN
           1
          ELSE
           0
      END w2w_sla_exception
FROM   _task t,
       operational_process op,
       support_group s,
       (SELECT a.search_code,
               a.NAME,
               a.total AS "Total Service Calls",
               decode(b.total_adjusted_miss, NULL, 0, b.total_adjusted_miss) "Missed SLA (Adjusted)",
               decode(c.total_unadjusted_miss, NULL, 0, c.total_unadjusted_miss) "Missed SLA (UnAdjusted)",
               decode(round(((a.total - b.total_adjusted_miss) / a.total) * 100, 2)
                     ,NULL
                     ,100
                     ,round(((a.total - b.total_adjusted_miss) / a.total) * 100, 2)) "Total Adjusted Yield %",
               decode(round(((a.total - c.total_unadjusted_miss) / a.total) * 100, 2)
                     ,NULL
                     ,100
                     ,round(((a.total - c.total_unadjusted_miss) / a.total) * 100, 2)) "Total UnAdjusted Yield %"
        FROM   ((SELECT COUNT(*) AS total, sg.search_code, sg.NAME
                 FROM   task t, operational_process op, support_group sg, person p
                 WHERE  sg.support_group_seq_id IN
                        (SELECT sg2.support_group_seq_id
                         FROM   support_group sg2
                         START  WITH sg2.search_code = p_target_name
                         CONNECT BY PRIOR sg2.support_group_seq_id = sg2.parent_support_group_seq_id)
                 AND    t.task_seq_id = op.task_seq_id
                 AND    t.task_seq_id = op.task_seq_id
                 AND    sg.support_group_seq_id = op.support_group_seq_id
                 AND    op.assigned_person_seq_id = p.person_seq_id
                 AND    sg.search_code = p_target_name
                 AND    t.task_type IN ('Inc')
                 AND    to_char(op.est_actual_end_datetime, 'MM-YYYY') = '02-2012'
                 AND    t.priority IS NOT NULL
                 GROUP  BY sg.search_code, sg.NAME)) a
        ) query_a
WHERE  t.task_seq_id = op.task_seq_id
AND    t.task_type IN ('Inc', 'SR')
AND    op.support_group_seq_id = s.support_group_seq_id
     --and s.name = 'L3 Service Management Data Warehouse Development'
AND    to_char(t._actual_end_datetime, 'MM-YYYY') = '02-2012'
AND
       query_a.search_code = s.search_code
AND
       query_a.NAME = s.NAMEI've put the join between the two queries as being on support_group.name and support_group.search_code. If you need to join on additional columns, you would need to include them in the inline view for query a (including group by) and add them to the join.
If that's not what you meant, maybe you could explain a bit more.
HTH
David

Similar Messages

  • Creation of a second Exchange 2013 server on a different site (with the roles of MBX and CAS) fails on prepare active directory and prepare schema.

    Hello everyone
    I have a network infrastructure  consisting of 3 sites, site A, site B, and site C. i have 2 domain controllers on every site, and the AD roles are on the primary domain controller on site A. On site A I have an Exchange 2013sp1 CU6.
    I want to create a second Exchange on Site B, with the roles of mailbox (the exchange on Site A will be first DAG member and the Exchange on Site B will be the second member of the DAG) and CAS.
    First question: Is my  thought correct about installaing on the same server mailbox and CAS server?
    Second question: how many DAG witnesses I need for the DAG? One per site, or one in general (for example located on site A)
    Third question: When I am trying to perform “Setup.exe /PrepareSchema /IAcceptExchangeServerLicenseTerms”  I receive the error
    “ Setup encountered a problem while validating the state of Active Directory:
     The Active Directory schema version (15303) is higher than Setup's version (15292). Therefore, PrepareSchema can't be executed.  See the Exchange setup log for more information on this error. For more information, visit:
    http://technet.microsoft.com/library(EXCHG.150)/ms.exch.setupreadiness.AdInitErrorRule.aspx “
    I tried  to run the PrepareSchema from  the ISO of Exchange 2013 SP1 and form the extracted content of Exchange 2013SP1 CU6 archive, but still receive the same error. Any ideas?
    Thanks in advance.

    Thank you for your answer,
    I have tried to run "Setup.exe /PrepareSchema /IAcceptExchangeServerLicenseTerms”  from
    Exchange 2013 CU6 media, but I still receive  the error:
    The Active Directory schema version (15303) is higher than Setup's version (15292). Therefore, PrepareSchema
    can't be executed.  See the Exchange setup log for more information on this error. For more information, visit:http://technet.microsoft.com/library(EXCHG.150)/ms.exch.setupreadiness.AdInitErrorRule.aspx “
    any ideas?

  • How do I use switch and case statements to fill more than one other field?

    Hi all,
    I'm new to the community.
    I'm trying to make an existing form more user friendly for my coworkers. I want to use a switch and case approach in a drop-down list field so that the selection fills two seperate other fields with different info related to the selection.
    I can already do this with one field, but if I add a second target field under an existing case the text doesn't appear there when I make the selection from the dropdown.
    Basically, I'm asking if I can do this:
    switch 
    (sNewSel){
       case "1": // Selection 1    Row2.Field1
    = "text for field 1";
        Row1.Field2 = "text for field 2"; 
        break;
    etc.
    It works if the "row1.field2" option isn't there, but not when it is present.
    Any takers?

    I'm not sure if I will be able to send you the form. There may be too much to redact.
    Would this last bit of code in the cell affect anything?
    if 
    (bEnableTextField)
    {Row2.Field1.access
    = "open"; // enable field
    Row2.Field1.caption.font.fill.color.value= "0,0,0"; // set caption to black
    That is, do I also need to repeat the same thing for the second target cell (Row1.Field2)?
    What would be possible hang ups that would prevent it from working correctly?
    Dave
    By the way, I'm not sure if my other attachment posted. I am trying again.

  • CASE STATEMENTS AND CASE EXPRESSIONS IN ORACLE9I PL/SQL

    제품 : PL/SQL
    작성날짜 : 2001-11-13
    CASE STATEMENTS AND CASE EXPRESSIONS IN ORACLE9I PL/SQL
    =======================================================
    PURPOSE
    아래의 자료는 Case 문에서 oracle 8.1.7과 Oracle 9i의 New Feature로 8.1.7에서는
    sqlplus 에서만 가능했고, 9i 부터는 pl/sql 까지 가능하다.
    Explanation
    1. Oracle 8.1.7 Feature
    Oracle 8.1.7 에서 Case 문은 Decode 문과 유사하지만, 기존의 decode 문을 쓰는 것보다
    더 많은 확장성과 Logical Power와 좋은 성능을 제공한다. 주로 나이와 같이 category 별로
    나눌때 주로 사용하고 Syntex는 아래와 같다.
    CASE WHEN <cond1> THEN <v1> WHEN <cond2> THEN <v2> ... [ELSE <vn+1> ] END
    각각의 WHEN...THEN 절의 argument 는 255 까지 가능하고 이 Limit를 해결하려면
    Oracle 8i Reference를 참조하면 된다.
    The maximum number of arguments in a CASE expression is 255, and each
    WHEN ... THEN pair counts as two arguments. To avoid exceeding the limit of 128 choices,
    you can nest CASE expressions. That is expr1 can itself be a CASE expression.
    Case Example : 한 회사의 모든 종업원의 평균 봉급을 계산하는데 봉급이 $2000보다 작은경우
    2000으로 계산을 하는 방법이 pl/sql을 대신하여 case function을 사용할 수 있다.
    SELECT AVG(CASE when e.sal > 2000 THEN e.sal ELSE 2000 end) FROM emp e;
    Case Example : 나이를 column으로 가지고 있는 customer table을 예로 들어보자.
    SQL> SELECT
    2 SUM(CASE WHEN age BETWEEN 70 AND 79 THEN 1 ELSE 0 END) as "70-79",
    3 SUM(CASE WHEN age BETWEEN 80 AND 89 THEN 1 ELSE 0 END) as "80-89",
    4 SUM(CASE WHEN age BETWEEN 90 AND 99 THEN 1 ELSE 0 END) as "90-99",
    5 SUM(CASE WHEN age > 99 THEN 1 ELSE 0 END) as "100+"
    6 FROM customer;
    70-79 80-89 90-99 100+
    4 2 3 1
    1 SELECT
    2 (CASE WHEN age BETWEEN 70 AND 79 THEN '70-79'
    3 WHEN age BETWEEN 80 and 89 THEN '80-89'
    4 WHEN age BETWEEN 90 and 99 THEN '90-99'
    5 WHEN age > 99 THEN '100+' END) as age_group,
    6 COUNT(*) as age_count
    7 FROM customer
    8 GROUP BY
    9 (CASE WHEN age BETWEEN 70 AND 79 THEN '70-79'
    10 WHEN age BETWEEN 80 and 89 THEN '80-89'
    11 WHEN age BETWEEN 90 and 99 THEN '90-99'
    12* WHEN age > 99 THEN '100+' END)
    SQL> /
    AGE_G AGE_COUNT
    100+ 1
    70-79 4
    80-89 2
    90-99 3
    Example
    2. Oracle 9i Feature
    Oracle 9i부터는 pl/sql에서도 case문을 사용할 수 있으면 이것은
    복잡한 if-else 구문을 없애고, C언어의 switch문과 같은 기능을 한다.
    아래의 9i pl/sql Sample 및 제약 사항을 보면 아래와 같다.
    Sample 1:
    A simple example demonstrating the proper syntax for a case
    statement
    using a character variable as the selector. See the section entitled
    'Restrictions' at the end of this article for details on which PLSQL
    datatypes may appear as a selector in a case statement or
    expression.
    - - - - - - - - - - - - - - - - Code begins here - - - - - - - - - - - -
    set serveroutput on
    declare
    achar char(1) := '&achar';
    begin
    case achar
    when 'A' then dbms_output.put_line('The description was Excellent');
    when 'B' then dbms_output.put_line('The description was Very Good');
    when 'C' then dbms_output.put_line('The description was Good');
    when 'D' then dbms_output.put_line('The description was Fair');
    when 'F' then dbms_output.put_line('The description was Poor');
    else dbms_output.put_line('The description was No such Grade');
    end case;
    end;
    - - - - - - - - - - - - - - - - Code ends here - - - - - - - - - - - -
    Sample 2:
    A simple example demonstrating the proper syntax for a case
    expression
    using a character variable as the selector. See the section entitled
    'Restrictions' at the end of this article for details on which PLSQL
    datatypes may appear as a selector in a case statement or
    expression.
    - - - - - - - - - - - - - - - - Code begins here - - - - - - - - - - - -
    set serveroutput on
    declare
    achar char(1) := '&achar';
    description varchar2(20);
    begin
    description :=
    case achar
    when 'A' then 'Excellent'
    when 'B' then 'Very Good'
    when 'C' then 'Good'
    when 'D' then 'Fair'
    when 'F' then 'Poor'
    else 'No such grade'
    end;
    dbms_output.put_line('The description was ' || description);
    end;
    - - - - - - - - - - - - - - - - Code ends here - - - - - - - - - - - -
    NOTE: The above simple samples demonstrate two subtle differences in the
    syntax
    required for case statements and expressions.
    1) A case STATEMENT is terminated using the 'end case' keywords; a
    case
    EXPRESSION is terminated using only the 'end' keyword.
    2) Each item in a case STATEMENT consists of one or more
    statements, each
    terminated by a semicolon. Each item in a case expression
    consists of
    exactly one expression, not terminated by a semicolon.
    Sample 3:
    Sample 1 demonstrates a simple case statement in which the selector
    is
    compared for equality with each item in the case statement body.
    PL/SQL
    also provides a 'searched' case statement as an alternative; rather
    than
    providing a selector and a list of values, each item in the body of
    the
    case statement provides its own predicate. This predicate can be any
    valid boolean expression, but only one case will be selected.
    - - - - - - - - - - - - - - - - Code begins here - - - - - - - - - - - -
    set serveroutput on
    declare
    achar char(1) := '&achar';
    begin
    case
    when achar = 'A' then dbms_output.put_line('The description was
    Excellent');
    when achar = 'B' then dbms_output.put_line('The description was Very
    Good');
    when achar = 'C' then dbms_output.put_line('The description was
    Good');
    when achar = 'D' then dbms_output.put_line('The description was
    Fair');
    when achar = 'F' then dbms_output.put_line('The description was
    Poor');
    else dbms_output.put_line('The description was No such Grade');
    end case;
    end;
    - - - - - - - - - - - - - - - - Code ends here - - - - - - - - - - - -
    Sample 4:
    This sample demonstrates the proper syntax for a case expression of
    the
    type discussed in Sample 3 above.
    - - - - - - - - - - - - - - - - Code begins here - - - - - - - - - - - -
    set serveroutput on
    declare
    achar char(1) := '&achar';
    description varchar2(20);
    begin
    description :=
    case
    when achar = 'A' then 'Excellent'
    when achar = 'B' then 'Very Good'
    when achar = 'C' then 'Good'
    when achar = 'D' then 'Fair'
    when achar = 'F' then 'Poor'
    else 'No such grade'
    end;
    dbms_output.put_line('The description was ' || description);
    end;
    - - - - - - - - - - - - - - - - Code ends here - - - - - - - - - - - -
    Sample 5:
    This sample demonstrates the use of nested case statements. It is
    also
    permissable to nest case expressions within a case statement (though
    it
    is not demonstrated here), but nesting of case statements within a
    case
    expression is not possible since statements do not return any value.
    - - - - - - - - - - - - - - - - Code begins here - - - - - - - - - - - -
    set serveroutput on
    declare
    anum1 number := &anum1;
    anum2 number := &anum2;
    answer number;
    begin
    case anum1
    when 1 then case anum2
    when 1 then answer := 10;
    when 2 then answer := 20;
    when 3 then answer := 30;
    else answer := 999;
    end case;
    when 2 then case anum2
    when 1 then answer := 15;
    when 2 then answer := 25;
    when 3 then answer := 35;
    else answer := 777;
    end case;
    else answer := 555;
    end case;
    dbms_output.put_line('The answer is ' || answer);
    end;
    - - - - - - - - - - - - - - - - Code ends here - - - - - - - - - - - -
    Sample 6:
    This sample demonstrates nesting of case expressions within another
    case
    expression. Note again the absence of semicolons to terminate both
    the
    nested case expression and the individual cases of those
    expressions.
    - - - - - - - - - - - - - - - - Code begins here - - - - - - - - - - - -
    set serveroutput on
    declare
    anum1 number := &anum1;
    anum2 number := &anum2;
    answer number;
    begin
    answer :=
    case anum1
    when 1 then case anum2
    when 1 then 10
    when 2 then 20
    when 3 then 30
    else 999
    end
    when 2 then case anum2
    when 1 then 15
    when 2 then 25
    when 3 then 35
    else 777
    end
    else 555
    end;
    dbms_output.put_line('The answer is ' || answer);
    end;
    - - - - - - - - - - - - - - - - Code ends here - - - - - - - - - - - -
    Although PL/SQL anonymous blocks have been used in all of the examples
    so far,
    case statements and expressions can also be used in procedures,
    functions, and
    packages with no changes to the syntax.
    The following samples are included for completeness and demonstrate the
    use of
    case statements and/or expressions in each of these scenarios.
    Sample 7:
    This sample demonstrates use of a case statement in a stored
    procedure.
    Note that this sample also demonstrates that it is possible for each
    of
    the items in the case body to consist of more than one statement.
    - - - - - - - - - - - - - - - - Code begins here - - - - - - - - - - - -
    set serveroutput on
    create or replace procedure testcasestmt ( anum IN number ) is
    begin
    case
    when anum = 1 then dbms_output.put_line('The number was One');
    dbms_output.put_line('In case 1');
    when anum = 2 then dbms_output.put_line('The number was Two');
    dbms_output.put_line('In case 2');
    when anum = 3 then dbms_output.put_line('The number was Three');
    dbms_output.put_line('In case 3');
    when anum = 4 then dbms_output.put_line('The number was Four');
    dbms_output.put_line('In case 4');
    when anum = 5 then dbms_output.put_line('The number was Five');
    dbms_output.put_line('In case 5');
    else dbms_output.put_line('The description was Invalid input');
    dbms_output.put_line('In the else case');
    end case;
    end;
    exec testcasestmt(&anum);
    - - - - - - - - - - - - - - - - Code ends here - - - - - - - - - - - -
    Sample 8:
    This sample demonstrates the use of a case statement in a stored
    package.
    - - - - - - - - - - - - - - - - Code begins here - - - - - - - - - - - -
    set serveroutput on
    create or replace package testpkg2 is
    procedure testcasestmt ( anum IN number );
    function testcasestmt_f ( anum IN number ) return number;
    end testpkg2;
    create or replace package body testpkg2 is
    procedure testcasestmt ( anum IN number ) is
    begin
    case
    when anum = 1 then dbms_output.put_line('The number was One');
    dbms_output.put_line('In case 1');
    when anum = 2 then dbms_output.put_line('The number was Two');
    dbms_output.put_line('In case 2');
    when anum = 3 then dbms_output.put_line('The number was Three');
    dbms_output.put_line('In case 3');
    when anum = 4 then dbms_output.put_line('The number was Four');
    dbms_output.put_line('In case 4');
    when anum = 5 then dbms_output.put_line('The number was Five');
    dbms_output.put_line('In case 5');
    else dbms_output.put_line('The description was Invalid input');
    dbms_output.put_line('In the else case');
    end case;
    end;
    function testcasestmt_f ( anum IN number ) return number is
    begin
    case
    when anum = 1 then dbms_output.put_line('The number was One');
    dbms_output.put_line('In case 1');
    when anum = 2 then dbms_output.put_line('The number was Two');
    dbms_output.put_line('In case 2');
    when anum = 3 then dbms_output.put_line('The number was Three');
    dbms_output.put_line('In case 3');
    when anum = 4 then dbms_output.put_line('The number was Four');
    dbms_output.put_line('In case 4');
    when anum = 5 then dbms_output.put_line('The number was Five');
    dbms_output.put_line('In case 5');
    else dbms_output.put_line('The description was Invalid input');
    dbms_output.put_line('In the else case');
    end case;
    return anum;
    end;
    end testpkg2;
    exec testpkg2.testcasestmt(&anum);
    variable numout number
    exec :numout := testpkg2.testcasestmt_f(&anum);
    print numout
    - - - - - - - - - - - - - - - - Code ends here - - - - - - - - - - - -
    Sample 9:
    This sample demonstrates the use of a case expression in a stored
    package.
    - - - - - - - - - - - - - - - - Code begins here - - - - - - - - - - - -
    set serveroutput on
    create or replace package testpkg is
    procedure testcase ( anum IN number );
    function testcase_f ( anum IN number ) return number;
    end testpkg;
    create or replace package body testpkg is
    procedure testcase ( anum IN number ) is
    anumber number := anum;
    anothernum number;
    begin
    anothernum :=
    case
    when anumber = 1 then anumber + 1
    when anumber = 2 then anumber + 2
    when anumber = 3 then anumber + 3
    when anumber = 4 then anumber + 4
    when anumber = 5 then anumber + 5
    else 999
    end;
    dbms_output.put_line('The number was ' || anothernum);
    end;
    function testcase_f ( anum IN number ) return number is
    anumber number := anum;
    anothernum number;
    begin
    anothernum :=
    case
    when anumber = 1 then anumber + 1
    when anumber = 2 then anumber + 2
    when anumber = 3 then anumber + 3
    when anumber = 4 then anumber + 4
    when anumber = 5 then anumber + 5
    else 999
    end;
    dbms_output.put_line('The number was ' || anothernum);
    return anothernum;
    end;
    end testpkg;
    variable numout number
    exec testpkg.testcase(&anum);
    exec :numout := testpkg.testcase_f(&anum);
    print numout
    - - - - - - - - - - - - - - - - Code ends here - - - - - - - - - - - -
    제약 사항
    다음의 databasetype은 case 문에서 지원되지 않는다.
    BLOB
    BFILE
    VARRAY
    Nested Table
    PL/SQL Record
    PL/SQL Version 2 tables (index by tables)
    Object type (user-defined type)
    All of these types except for object types face a similar restriction
    even for if statements (i.e. they cannot be compared for equality directly) so this is unlikely to change for these types. Lack of support for object types is simply an implementation restriction which may be relaxed in future releases.
    Reference Ducumment
    Oracle 8.1.7 Manual
    NOTE:131557.1

    I have done the following code but doesn't
    like the statement of - "case(butNext)". What do you mean "doesn't like" -- did you get an error message?
    I'm guessing it won't compile because you're trying to switch on a Button.
    I tried something
    like "g.fillOval(100,50,70,90, BorderLayout.NORTH)"...no that doesn't make sense. You only use BorderLayout.NORTH when you're adding components to a BorderLayout layout manager. An oval is not a component and fillOval isn't adding a component and Graphics is not a Panel or layout manager.
    Would appreciate it if someone could tell me how to position
    shapes using the graohic method. I think the problem is that you're confusing shapes with components.

  • I would like to know how can i compare a switch case 1 and case 2 in C# is it possible to do that? obs i am a begginer :)

    i would like to know how can i compare a switch case 1 and case 2 in C# is it possible to do that? obs i am a begginer :) I tried to do it with search and sort but it did not go well

    let me give you an example if you add a word case 1( lagg ord) how can i compare that word with case 2 words ( in case 2  already exist 5 words)
    here is the my program 
    using System;
    namespace ConsoleApplication1
        class Program
            static void Main(string[] args)
                //Meny
                Console.WriteLine("\n HÄNGA GUBBE\n");
                Console.WriteLine(" 1) Lägg till ord");
                Console.WriteLine(" 2) Lista alla ord");
                Console.WriteLine(" 3) Spela");
                Console.WriteLine(" 4) Avsluta");
                bool utgång = false;
                do
                    int Valet;
                    Console.Write("\n\tVälj 1-4: \n ");
                    try
                        Valet = int.Parse(Console.ReadLine());
                    catch (Exception)
                        Console.WriteLine("Du skriver fel character!\n" +
                            "\nSkriv bara mellan 1 och 4");
                        continue;
                    switch (Valet)
                        case 1:
                            Console.WriteLine("\n lägg ett till ord! ");
                          var input = Console.ReadLine();
                            break;
                        case 2:
                            Console.WriteLine("\n Lista med alla ord :\n");
                            string[] array = { " Lev", " Skratta", " Gledje", " Gråt", " Njut" };
                            Array.Sort<string>(array);
                            foreach (var c in array)
                                Console.WriteLine(c);
                            Console.WriteLine("\n");
                            break;
                        case 3:
                            string guesses, bokstäver;
                            Console.Write("\n Hur många fel får man ha? ");
                            guesses = (Console.ReadLine());
                            Console.WriteLine(" Utmärkt, då spelar vi!\n");
                            Console.WriteLine(" Felgisningar :" + "0/" + guesses);
                            Console.Write(" Gissade bokstäver ");
                            bokstäver = (Console.ReadLine());
                            Console.WriteLine("Aktuellt ord");
                            Console.Write("Gissa bokstav : " + bokstäver + " \n");
                            break;
                        case 4:
                            Console.WriteLine("\n  HEJ DÅ! \n");
                            Console.Beep();
                            utgång = true;
                            break;
                        //avbryter while loopen, avslutar spelet
                } while (!utgång);

  • I Need a Good HD and Case Which One to Buy?

    I need an external, large capacity (350GB +) HD for my iBook G4. Can anyone recommend a good HD and case? I need to be able to boot from the external HD. Thanks.

    Mostly it saves money since you don't have to buy separate drives.
    But its also nice to keep certain things separated. I back up two Macs to a single drive, but separate partitions. OS-X thinks they are separate drives and SuperDuper recognises which drive belongs with which Mac.
    -marc

  • Flex Cube - Deposits and CASA documentation

    Flex Cube - Deposits and CASA documentation: someone could help me to find documentation and information about CA SA and Deposits Flex CUbe MOdule ? Thanks.

  • FSCM SAP 5.0 Dispute Management-record and case model-dispute cas model.xml

    Hello,
    I am using the W21: Dipsute Management Building Block Configuration Guide.doc
    At the first step, creating a case record model, the configuration guide refers to a file:
    6.     In the toolbar of the Modeler in the upper middle section select Model >> Load local file and open the file - dispute case model.xml -.
    I do not have this file available, does anyone have any idea how to resolve this?
    -     How can I obtain this file
    -     Is this file necessary, to create a case record model
    Thanks for your help.
    Kind regards,
    Santiago

    Hi Santiago,
    This was tricky for me too.  Execute tran UDM_DISPUTE.  Change your RMS ID (left side, middle box, icon with two overlapping squares) to UDM_DISPUTE. In the same box, expand Record and Case Record Models.  Double click on Modeler for Case Records in Dispute Management.  This brings up a search box.  Click on execute Search. Double click on the Dispute Management entry in the lower box.  This gives you the standard model.  You can download this, using the Other Model Functions.
    Then change to your custom RMS ID (ex. ZUDM_DISPUTE).  Expand Record and Case Record Models.  Right click on Modeler for Case Records in Dispute Management and select Create.  Then upload the standard model into your RMS.  Then you can customize the model as you wish.  Hope that helps! 
    Beth

  • Diff b/w IF/ENDIF and CASE statement?

    Hi all,
    Plz let me know the difference between IF and CASE statements.Which one is better to be used in general...and are there any specific situations where we have to go for CASE insted of IF.
    Rgds,
    Reddy.

    Hi,
    Case statement is good for performance wise because here we declare cases
    and according to these cases program will be executed.
    When we use if statement then the cursur goes to in the loop, when ever
    the loop is not complete till then the programme will not execute.
    Thats by in performance basis the case statement is good.
    Let me try and explain using an example...
    1) For IF statement...
    Suppost you have a variable color..and you are checking it against color names.
    then your code will be
    IF COLOR == 'BLUE'.
        statements
    ELSEIF COLOR == 'BLACK'.
        statements.
    ...and so on....
    ENDIF.
    But if you use CASE Statement
    CASE COLOR.
    when 'BLUE'.
       statements.
    when 'BLACK'.
      statements.
    so follows that CASE is easy to use and performance wise is also better.
    Regards,
    Priyanka.

  • Diff between decode and case

    Hi
    I need small clarification about difference between decode and case
    Thanks who visit my thread

    And for those people who can't be ar$ed to follow links...
    Decode allows for conditional output where the conditions are straightforward matches between values.
    Case allows for regular conditions to be used such as greater than, less than etc.
    Some of the things done by case can be achieved through decode as well but in a more convoluted manner than simply using case.
    ;)

  • Decode and Case

    Hi,
    What is the difference between decode and case?
    What are the cases in which we can use Decode and case
    Thanx

    you can not put Search CASE statements by using DECODE
    Eg:
    SELECT AVG(CASE WHEN e.salary > 2000 THEN e.salary ELSE 2000 END) "Average Salary" FROM employees e;Can't we?
    select avg(decode(sign(e.salary - 2000), 1, e.salary, 2000)) "Average Salary" from employees e;

  • OBIEE 11g RPD and case study document required for practice

    Hi OBIEE guru's,
    Could you please help me by posting OBIEE 11g sample RPD and case study document for creating Answers and Dashboards.
    I need to brushup my skills on creating Answers and Dashboards.
    Thanks in advance.

    Satya,
    have you looked at the sample app. This has many different cases and you can "play" with the data yourself. Quite powerful:
    http://www.oracle.com/technetwork/middleware/bi-foundation/obiee-samples-167534.html
    have fun
    alex

  • Query that treats "accents insensitive" and "case insensitive"

    I need to do one query that treats "accents insensitive" and "case insensitive" if possible too.
    I need to have the query below ajusted to return both accent or not accent words:
    with t as
    ( select 'xxxELEIÇÕESyyy' text from dual union all
    select 'xxxELEIÇOESyyy' text from dual union all
    select 'xxxELEICÕESyyy' text from dual)
    select text from t
    where text like '%eleicoes%'; --> i need some filter that result true for both 3 lines

    SQL> with t as
      2  ( select 'xxxELEIÇÕESyyy' text from dual union all
      3  select 'xxxELEIÇOESyyy' text from dual union all
      4  select 'xxxeleiÇOESyyy' text from dual union all
      5  select 'xxxELEICÕESyyy' text from dual)
      6  select text from t
      7  where regexp_like(t.text, '(x|X){3}(ELEI|elei){1}([CcÇç]{1})([ÕOõo]{1})(ES|es){1}(y|Y){3}')
      8 
    SQL> /
    TEXT
    xxxELEIÇÕESyyy
    xxxELEIÇOESyyy
    xxxeleiÇOESyyy
    xxxELEICÕESyyy

  • How to query using 3 optional inputs and case insensitive using SQL?

    Hi Folks,
    I am having trouble with the following query:
    select *
    from t1
    where (1=1)
    and lower(fname) like lower ('%mary%')
    and lower(lname) like lower ('%smith%')
    and lower(status) like lower ('%%')
    I need all three statements in the where clause to be completely optional and case insensitve.
    if I just write the following:
    (1=1)
    and lower(fname) like lower ('%mary%')
    and lower(lname) like lower ('%%') <-- Need to ignore this line
    and lower(status) like lower ('%%') <-- need to ignore this line
    nothing is returned. How do I ignore the 2nd and third lines using SQL only. I know about the ask TOM Article using procedures, but I need to do this using SQL only
    thanks in advance
    Edited by: user2184537 on Oct 16, 2009 9:40 AM
    Edited by: user2184537 on Oct 16, 2009 10:10 AM

    Hi,
    Is this query generated dynamically? (That's the only reason I can see for saying "WHERE 1 = 1".)
    If so, test the parameters for NULL, and only add them if a value was given.
    Failing that, you can explicitly test for NULL parameters
    where   (     lower(fname)  = '%' || lower (:p_fname) || '%'
         OR     :p_fname     IS NULL
    and     (     lower(lname)  = '%' || lower (:p_lname) || '%'
         OR     :p_lname     IS NULL
    and     (     lower(status) = '%' || lower (:p_status) || '%'
         OR     :p_status    IS NULL
         )Did you really mean to have all those '%''s? '%' is a wildcard in LIKE operations, but not when using =.
    Perhaps you should be saying:
    where   (     lower(fname)  = lower (:p_fname)
         OR     :p_fname     IS NULL
    and     (     lower(lname)  = lower (:p_lname)
         OR     :p_lname     IS NULL
    and     (     lower(status) = lower (:p_status)
         OR     :p_status    IS NULL
         )You're already handling case-sensitivity, by using LOWER in all the comparisons.
    Unfortunately, you can't just say something like:
    WHERE   LOWER (fname) = LOWER (NVL (:p_fname, fname))because that would discartd rows where fname IS NULL when :p_name is also NULL.
    Edited by: Frank Kulash on Oct 16, 2009 12:54 PM

  • Redundant Hub and CAS roles for exchange server

    Hello ,
    currently we have 2 mailbox servers , 1 DAG server and 1 HUB,CAS server ( hub and cas roles in same server )
    i am looking to have a backup server incase the hub CAS server goes down  ..  or to have a redundant server for HUBCAS  incase if it goes down the other one will go up and the users will use the second one automatically
    how can i achieve that ? 
    appreciated your help

    Hello,
    If you use exchange 2010 server, I recommend you deploy multiple CAS servers as member of CAS array.
    As your requirement, you need to deploy CAS NLB, the failover will occurs automatically.
    Here is an article for your reference.
    http://technet.microsoft.com/en-us/library/ff625247(v=exchg.141).aspx
    Cara Chen
    TechNet Community Support

Maybe you are looking for

  • Error when connecting to MySQL Database

    I am trying to connect to MySQL and receive an error everytime. I have attempted to talk to Bluehost (who my site is hosted thru) and they said it is not on their end and not something they can help me with. I set up a new MySQL Database with Bluehos

  • Iphone quartz border around line

    Hello, what's the best way to draw a (solid black) border around a line in quartz for iphone? I'm drawing lines on streets on a map and if the line is yellow (which is a legit use case), it blends in with the street color. One thing I could do is lay

  • HT4356 iPad printing to file. I just want file my print image so I can email it. How?

    All I want to do is print a web page to file so I can refer to it later. (insurance quote details -impossible to recall without starting from scratch) how do I copy a web page IMAGE for later review?

  • About a stolen mini!!!

    IF my ipod mini was already stolen, and let's say i go to the apple store and tell them i wanna buy some warranty, then can i get a new mini ipod? without pay because i already bought warranty?? how does it work??

  • MemTool for Solaris 10?

    Hi All Do you know of any MemTool package, as is available for solaris 7,8 and 9, for Solaris 10? Pointer will be of great help. TIA