Loop  wirh for using case when

Hello,
i wanna use a loop over a select
but this select depend on a variable value
so, here is what i did:
CREATE OR REPLACE Procedure dispatch_pat(perId in number,shortlist_ID in number,orId in number, typeDonnee in number) is
orVar number(7);
test number;
begin
for orVar in (case when (orId <> 0) then (select OR_ID as id from ordre_regrpmt where or_id=orId) else (select OR_ID as id from ordre_regrpmt where or_id in ( select or_id from DETAIL_SHORT_LIST where ORSHORTLIST_ID=shortlist_ID)) end) loop
select count(*) into test from ajust_pat where (OR_ID=orVar) and (PER_ID=perId);
if (test=0) then
insert into ajust_pat (OR_ID,PER_ID,GENE_ID) values (orVar.id,perId,typeDonnee);
end if;
end loop;
end;
but i got this error :
On line: 5
PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
( - + case mod new not null others <an identifier>
<a double-quoted delimited-identifier> <a bind variable> avg
Regards
Sallemel

Try this code
/* Formatted on 2009/03/06 08:23 (Formatter Plus v4.8.8) */
CREATE OR REPLACE PROCEDURE dispatch_pat (
   perid          IN   NUMBER,
   shortlist_id   IN   NUMBER,
   orid           IN   NUMBER,
   typedonnee     IN   NUMBER
IS
   orvar   NUMBER (7);
   TEST    NUMBER;
BEGIN
   IF orid = 0
   THEN
      FOR orvar IN (SELECT or_id AS ID
                      FROM ordre_regrpmt
                     WHERE or_id = orid)
      LOOP
         SELECT COUNT (*)
           INTO TEST
           FROM ajust_pat
          WHERE (or_id = orvar) AND (per_id = perid);
         IF (TEST = 0)
         THEN
            INSERT INTO ajust_pat
                        (or_id, per_id, gene_id
                 VALUES (orvar.ID, perid, typedonnee
         END IF;
      END LOOP;
   ELSE
      FOR orvar IN (SELECT or_id AS ID
                      FROM ordre_regrpmt
                     WHERE or_id IN (SELECT or_id
                                       FROM detail_short_list
                                      WHERE orshortlist_id = shortlist_id))
      LOOP
         SELECT COUNT (*)
           INTO TEST
           FROM ajust_pat
          WHERE (or_id = orvar) AND (per_id = perid);
         IF (TEST = 0)
         THEN
            INSERT INTO ajust_pat
                        (or_id, per_id, gene_id
                 VALUES (orvar.ID, perid, typedonnee
         END IF;
      END LOOP;
   END IF;
END;
/

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 '<', '>', '='

  • How to use case when statements in ODI

    I need to put conditional logic before DVM look up in ODI. In the expression editor I put the following statement:-
    CASE WHEN POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME='RCS' THEN POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME=EBIZ_CELL.CELL_DATA
    WHEN POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME='FDC' THEN CONCAT(POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME,POC_JOURNAL_TEMP_SOURCE_TBL.BOOK_CODE)=EBIZ_CELL.CELL_DATA
    END
    It did not work,
    Under Operators ->All Executions, found the error:-
    905 : 42000 : java.sql.SQLException: ORA-00905: missing keyword
    The description in Session Task contained:-
    select     
         C1_JOURNAL_TEMPL
    from     APPS.POC_JOURNAL_TEMP_SOURCE_TBL POC_JOURNAL_TEMP_SOURCE_TBL, APPS.C$_0POC_JOURNAL_TEMP_TARGET_TB
    where     
         (1=1)
    And (CASE
    WHEN POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME='RCS'
    THEN POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME=C2_CELL_DATA
    WHEN POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME='FDC'
    THEN CONCAT(POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME,POC_JOURNAL_TEMP_SOURCE_TBL.BOOK_CODE)=C2_CELL_DATA
    END)
    Checked the above code in PL/SQL Developer but it gave errors.
    In PL/SQL developer tried to check a simple query using case-when but even that is giving errors in the case-when portion.
    The query is as follows:-
    select phase_code, accounting_period, sum(eff_cc) as BD_Eff_QTD
    from prj_detail
    where
    case POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME
    when 'EXT'
    then
    1
    when 'RAC'
    then
    2
    when 'XXX'
    then
    3
    else
    end
    I would like to know what is wrong with the above code.
    Please let me know what is the correct way of using case-when in PL/SQL as well as in ODI.

    Your ODI case statement and PL/SQL Case statement both looks confusing.
    You are writing case statement under where clause which is not a good practise. If you want to implement logic like-
    select a,b,c from <table>
    where
    when cond^n^ 1 then do 1
    when cond^n^ 2 then do 2
    then better you seperate your query for each filter and do a union, in other words-
    select a,b,c from <table>
    where cond^n^ 1
    union
    select a,b,c from <table>
    where cond^n^ 2
    If you are writing case staement to retrieve a value/column (EBIZ_CELL.CELL_DATA) then no need to include it under filter.
    ODI case for column EBIZ_CELL.CELL_DATA will be:
    CASE
    WHEN POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME='RCS'
    THEN POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME
    WHEN POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME='FDC'
    THEN CONCAT(POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME,POC_JOURNAL_TEMP_SOURCE_TBL.BOOK_CODE)
    END
    Pl/SQL query-
    select phase_code, accounting_period,
    case POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME
    when 'EXT'then 1
    when 'RAC' then 2
    when 'XXX' then 3
    else 'default value' --- (if no else needed then can also remove else part)
    end,
    sum(eff_cc) as BD_Eff_QTD
    from prj_detail
    Suggested as per what is understood, hope it helps.
    Edited by: 939451 on Jul 5, 2012 12:47 AM
    Edited by: 939451 on Jul 5, 2012 12:48 AM

  • Using Case When

    I have a situation where i need to write a case when sql expression to fetch certain rows from a table.
    How to use CASE WHEN THEN ELSE END in a report query ?
    Explanation with a simple example will be of great help.
    thanks

    The javadoc for oracle.toplink.expressions.Expression
    contains some information.
    The following is an example of how to build the case statement.
    This will use case to replace the keys in the caseTable with the values. The default value (the ELSE) is provided as the second argument.
         Hashtable caseTable = new Hashtable(3);
         caseTable.put("Bob", "Bobby");
         caseTable.put("Susan", "Susie");
         caseTable.put("Eldrick", "Tiger");
         Expression expression = builder.get("firstName").caseStatement(caseTable, "No-Nickname").equal("Bobby");

  • How to use case when function to calculate time ?

    Dear All,
    May i know how to use case when function to calculate the time ?
    for the example , if the First_EP_scan_time is 12.30,  then must minus 30 min.  
    CASE WHEN FIRSTSCAN.EP_SHIFT <> 'R1' AND FIRSTSCAN.EP_SHIFT <> 'R2'
    THEN ROUND(CAST((DATEDIFF(MINUTE,CAST(STUFF(STUFF((CASE WHEN SHIFTCAL.EP_SHIFT = 'N1'
    THEN CONVERT(VARCHAR(8),DATEADD(DAY,+1,LEFT(FIRSTSCAN.EP_SCAN_DATE ,8)),112) + ' ' + REPLACE(CONVERT(VARCHAR(8),DATEADD(HOUR,+0,SHIFTDESC.EP_SHIFT_TIMETO + ':00'),108),':','')
    ELSE LEFT(FIRSTSCAN.EP_SCAN_DATE ,8) + ' ' + REPLACE(CONVERT(VARCHAR(8),DATEADD(HOUR,+0,SHIFTDESC.EP_SHIFT_TIMETO + ':00'),108),':','') END),12,0,':'),15,0,':') AS DATETIME),CAST(STUFF(STUFF(LASTSCAN.EP_SCAN_DATE,12,0,':'),15,0,':') AS DATETIME)) / 60.0 - 0.25) AS FLOAT),2)
    ELSE ROUND(CAST((DATEDIFF(MINUTE,CAST(STUFF(STUFF(FIRSTSCAN.EP_SCAN_DATE,12,0,':'),15,0,':') AS DATETIME),CAST(STUFF(STUFF(LASTSCAN.EP_SCAN_DATE,12,0,':'),15,0,':') AS DATETIME)) / 60.0) AS FLOAT),2) END AS OTWORK_HOUR

    Do not use computations in a declarative language.  This is SQL and not COBOL.
    Use a table of time slots set to one more decimal second of precision than your data. You can now use temporal math to add it to a DATE to TIME(1) get a full DATETIME2(0). Here is the basic skeleton. 
    CREATE TABLE Timeslots
    (slot_start_time TIME(1) NOT NULL PRIMARY KEY,
     slot_end_time TIME(1) NOT NULL,
     CHECK (start_time < end_time));
    INSERT INTO Timeslots  --15 min intervals 
    VALUES ('00:00:00.0', '00:14:59.9'),
    ('00:15:00.0', '00:29:59.9'),
    ('00:30:00.0', '00:44:59.9'),
    ('00:45:00.0', '01:00:59.9'), 
    ('23:45:00.0', '23:59:59.9'); 
    Here is the basic query for rounding down to a time slot. 
    SELECT CAST (@in_timestamp AS DATE), T.start_time
      FROM Timeslots AS T
     WHERE CAST (@in_timestamp AS TIME)
           BETWEEN T.slot_start_time 
               AND T.slot_end_time;
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Is there a known issue for using IE11 when using business catalyst cms

    Is there a known issue for using IE11 when using business catalyst cms?  I have a client trying to update pages on her site using IE11 and the it says it updates successfully, but the new content is not saved.

    I concur with Barry; I see no significant difference in using the Home button vs. the gestures. But the "fade" effect is part of iOS 7.1 and there's no way to disable it that I know of.
    Regards.

  • How to use case when in Select qry?

    Hi Friends,
    I want to use Case when in Select qry, my situation is like this
    SELECT bmatnr blgort bj_3asiz bmat_kdauf b~mat_kdpos
           SUM( ( case when bshkzg = 'S' then bmenge else 0 END ) -
            ( case when bshkzg = 'H' then bmenge else 0 END ) ) AS qty
           INTO corresponding fields of table it_projsal
        FROM mseg AS b
            INNER JOIN mkpf AS a ON bmblnr = amblnr
                                AND bmandt = amandt
        WHERE abudat  < '20061201' AND blgort IN ('1050')
          and b~mandt = '350'
        GROUP BY bmatnr bj_3asiz bmat_kdauf bmat_kdpos b~lgor
    If we give like this it gives an error.
    Please help me, how to use or handle in select qry itself.
    Regards
    Shankar

    this is not a way to select data from the DB tables.
    first get all the data from the DB tables then u have to do SUM Ups .
    Regards
    prabhu

  • Update multiple rows using CASE WHEN

    I have the table ACCOUNT of structure as follow: 
    ACCOUNT_ID
    ACCOUNT_STATUS
    004460721
    2
    042056291
    5
    601272065
    3
    I need to update the three rows at once using one SELECT statement such that, the second column will be 5, 3, 2 respectively.
    I used the following query but seems there is something missing
    UPDATE ACCOUNT
    SET ACCOUNT_STATUS = CASE  
    WHEN ACCOUNT_STATUS = '004460721' THEN 5 
    WHEN ACCOUNT_STATUS = '042056291' THEN 3 
    WHEN ACCOUNT_STATUS = '601272065' THEN 2 
    WHERE ACCOUNT_ID IN ('004460721','042056291','601272065') 
    My question, is this way correct? if no, can I use CASE WHEN statement and how or I only have choice of using SUB-SELECT to acheive that in one statement?

    Hi,
    Hawk333 wrote:
    I have the table ACCOUNT of structure as follow:
    ACCOUNT_ID
    ACCOUNT_STATUS
    004460721
    2
    042056291
    5
    601272065
    3
    I need to update the three rows at once using one SELECT statement such that, the second column will be 5, 3, 2 respectively.
    I used the following query but seems there is something missing
    UPDATE ACCOUNT
    SET ACCOUNT_STATUS = CASE  
    WHEN ACCOUNT_STATUS = '004460721' THEN 5 
    WHEN ACCOUNT_STATUS = '042056291' THEN 3 
    WHEN ACCOUNT_STATUS = '601272065' THEN 2 
    WHERE ACCOUNT_ID IN ('004460721','042056291','601272065') 
    My question, is this way correct? if no, can I use CASE WHEN statement and how or I only have choice of using SUB-SELECT to acheive that in one statement?
    What happens when you try it?
    Did you mean "WHEN ACCOUNT_ID = ..."?
    A CASE expressions always needs an END keyword.
    Depending on your requirements (that is, why are those rows being changed, and how do you determine the new values) a CASE expression in an UPDATE statement, similar to what you posted, could be a good way to do it.  MERGE (instead of UPDATE) would also be an option, especially if you want to avoid updating rows that already happen to have the correct values.

  • Insert using case when

    hello ,
    i wanna use "case when" statement in the insert , i implement it like this :
    currentyear:=1;
    insert into test1 (ATTRIB1,ATTRIB2) values ((case when currentyear=1 then 'ok' else 'notOK' end),'val2' );
    but it didn't work, i got this error :
    ORA-14551: cannot perform a DML operation inside a query
    Regards
    Elyes
    Edited by: user10393090 on 5 janv. 2009 03:32

    Better approach is ->
    insert into test1 (ATTRIB1,ATTRIB2)
    select case
             when &currentyear=1 then
              'ok'
           else
             'notOK'
           end AS attrib1,
           'val2' AS attrib2
    from dual;N.B.: Not Tested...
    Regards.
    Satyaki De.

  • Using CASE WHEN for Essbase column in OBIEE 11g

    Hi all,
    I have a business model in OBIEE 11g, taking the source from Essbase 11. The measures of the Essbase cube in the physical layer is flattened, and the aggregations for the measures are set to SUM.
    The Product dimension has 5 generations. In Product logical table, I created a logical column called "Product Grouping" using a simple CASE WHEN formula:
    CASE
    WHEN "TEST"."Product"."Gen5,Product" IN ('100-10', '100-20', '200-10', '300-10') THEN 'Group 1'
    WHEN "TEST"."Product"."Gen5,Product" IN ('100-30', '200-20') THEN 'Group 2'
    ELSE 'Group 3'
    END
    Problems:
    1. If I don't place this "Product Grouping" in the logical level/hierarchy, I got error in the report when I simply show Product Grouping and a measure.
    2. If I place this "Product Grouping" in the logical level/hierarchy (on the 5th level), no more error in the report when I simply show "Product Grouping" and a measure. The measure value also shows the correct SUM (group by). However, when I add "Gen1,Product" the "Product Grouping" and the measure value suddenly becomes not grouped by.
    Has anyone ever tried and encountered something like this? Any thoughts?
    Thank you very much!

    Hi Deepak, thansk for the suggestion.
    However, I can't use calculated item for this report because:
    1. incorrect result will be shown when my measures involve a formula to derive a percentage value.
    2. calculated item is not available if we do "combine requests" (or union) in 11g.
    Any thoughts anyone on how to solve this? Is this just me, or it's a bug?
    Thank you very much.

  • Using CASE WHEN to change background color

    I've done this many times without any problems, but this time its a little different situation and I can't get it to work.
    I can use this CASE WHEN statement without any problems.
    CASE WHEN
    NAME in
    (select EMP_REQUEST_NAME from OAX_PTA_LOGGER where
    EMP_REQUEST_NAME = NAME and
    EMP_ASSIST_NAME is null and
    JOB_NO = :P24_JOB_NO)
    THEN
    '<span style="color:brown;background-color:yellow">'||NAME||'</font>'
    ELSE "NAME"
    END
    "NAME",
    But I Cant Get This One to Work
    CASE WHEN
    NAME in
    (select EMP_REQUEST_NAME from OAX_PTA_LOGGER where
    EMP_REQUEST_NAME = NAME and
    EMP_ASSIST_NAME is null and
    JOB_NO = :P24_JOB_NO)
    THEN
    '<span style="color:brown;background-color:yellow">'||NAME_DISPLAY||'</font>'
    ELSE "NAME"
    END
    "NAME" NAME_DISPLAY,
    I'm sure that the problem lies with <"NAME" NAME_DISPLAY> but I can't find my way to a solution.
    Does anyone have any ideas for me?

    I've done this many times without any problems, but this time its a little different situation and I can't get it to work.
    I can use this CASE WHEN statement without any problems.
    CASE WHEN
    NAME in
    (select EMP_REQUEST_NAME from OAX_PTA_LOGGER where EMP_REQUEST_NAME = NAME and
    EMP_ASSIST_NAME is null and
    JOB_NO = :P24_JOB_NO)
    THEN
    (ignore this) span style="color:brown;background-color:yellow">'||NAME||' (ignore this)
    ELSE "NAME"
    END
    "NAME",
    But I Cant Get This One to Work
    CASE WHEN
    NAME in
    (select EMP_REQUEST_NAME from OAX_PTA_LOGGER where EMP_REQUEST_NAME = NAME and
    EMP_ASSIST_NAME is null and
    JOB_NO = :P24_JOB_NO)
    THEN
    (ignore this) span style="color:brown;background-color:yellow">'||NAME||' (ignore this)
    ELSE "NAME"
    END
    "NAME" NAME_DISPLAY,
    I'm sure that the problem lies with <"NAME" NAME_DISPLAY> but I can't find my way to a solution. Does anyone have any ideas for me?

  • Using case when to an aggregate function

    Hi,
    I have a sql statement like below,
    Select CASE WHEN (Sum(Amount) Over (Partition By Name),1,1) = '-' THEN 0 ELSE Sum(Amount) Over (Partition By Name) END AS Amount_Person
    From tbPerson
    But when I run the sql statement above I got error ORA-00920: invalid relational operator. What I'm trying to do is when the total amount for each person is negative then it will return 0 else it will return the positive value. I dont want to use the GROUP BY function. Is there any other way than using the Sum Over function? Thanks

    Like this?
    SELECT CASE WHEN Sum(Amount) Over (Partition By Name) < 0 THEN 0
                ELSE Sum(Amount) Over (Partition By Name)
           END AS Amount_Person
    FROM tbPerson
    ;or using GREATEST function :
    SELECT GREATEST(
             Sum(Amount) Over (Partition By Name)
           , 0
           ) as Amount_Person
    FROM tbPerson
    ;Edited by: odie_63 on 24 févr. 2011 09:12

  • Using CASE WHEN in PL/SQL package

    I am trying to convert the values in a selected column into 1 and 0 so that I can display all 1s in one column, all 0s in another. I am doing this in a PL/SQL package. However ORACLE compiler does not like the CASE construct.
    Does anyone know how to group values in a column into several new columns. If CASE WHEN construct is not doable in PL/SQL, what alternatives are there? Thanks.
    /******* My package starts here *******/
    CREATE OR REPLACE PACKAGE TEST_NEED AS
    PROCEDURE procTEST_NEED(STARTING_DATE IN VARCHAR2);
    END CVRR_MON_NEED;
    CREATE OR REPLACE PACKAGE BODY TEST_NEED
    AS
    PROCEDURE procTEST_NEED(STARTING_DATE IN VARCHAR2)
    IS
    TEST_START DATE := TO_DATE(STARTING_DATE,'MM/DD/YYYY');
    CURSOR v_Cursor IS
    SELECT A.D_CODE, A.M_CODE, TEST_START , C.C_NAME,C.P_ID,
    SUM(CASE WHEN MONTHS_BETWEEN(SYSDATE, D.P_DOB)/12 > 40 AND MONTHS_BETWEEN(SYSDATE, D.P_DOB)/12 <85 AND B.B_CODE IN '11.1','222.2','272.4') THEN 1 ELSE 0 END) QUALIFIED
    FROM A, B, C, D
    WHERE A.ID = B.B_ID
    AND RTRIM(A.P_CODE) = C.P_CODE
    AND A.P_ID = D.P_ID
    AND A.P_ID < 99999999999999999999
    AND A.E_DATETIME < SYSDATE
    GROUP BY A.D_CODE, A.M_CODE, TEST_START , C.C_NAME,C.P_ID;
    v_RecordHolder v_Cursor%ROWTYPE;
    BEGIN
    OPEN v_Cursor;
    FETCH v_CursorINTO v_RecordHolder ;
    WHILE v_Cursor%FOUND LOOP
    look for records in another table with matching keys of the cursor
    if found then update by incrementing the existing values in the matching records with values of the current currsor row
    else insert the current cursor row
    FETCH v_Cursor INTO v_RecordHolder ;
    END LOOP;
    END procTEST_NEED;
    END TEST_NEED;

    I am trying to convert the values in a selected
    column into 1 and 0 so that I can display all 1s in
    one column, all 0s in another. I am doing this in a
    PL/SQL package. However ORACLE compiler does not
    like the CASE construct.
    Does anyone know how to group values in a column into
    several new columns. If CASE WHEN construct is not
    doable in PL/SQL, what alternatives are there?
    Thanks.
    CURSOR v_Cursor IS
    SELECT A.D_CODE, A.M_CODE, TEST_START ,
    , C.C_NAME,C.P_ID,
    SUM(CASE WHEN MONTHS_BETWEEN(SYSDATE, D.P_DOB)/12 >
    40 AND MONTHS_BETWEEN(SYSDATE, D.P_DOB)/12 <85 ANDB.B_CODE IN '11.1','222.2','272.4') THEN 1 ELSE 0
    END) QUALIFIEDUse the Decode function. This has been around in oracle SQL for ages and works like a case construct.
    You would do something like
    select ...
    sum( decode (MONTHS_BETWEEN(SYSDATE, D.P_DOB)/12 >
    40 AND MONTHS_BETWEEN(SYSDATE, D.P_DOB)/12 <85 AND
    B.B_CODE IN ('11.1','222.2','272.4') 1,0 )

  • Using :case when  in where clause

    Hello,
    I need some help with using of case statement in a where clause
    Table that contains info about employees taking some coursework:
    Class (values could be SAP, ORACLE, JAVA)
    Code (if Class is SAP then CODE is not null; if class is any other CODE is NULL)
    Start Date (date they began class not null)
    End Date (date then ended the class - could be null)
    Employee Level(numbers from one through five)
    I need a single LOV in forms that should show Employee_Level for input class,code,date.
    How to do this?
    I started off with this but get 'missing statement error'
    select distinct employee_level from e_course
       where (
       case when &class='SAP' then code ='1' and start_date > to_date('20000101','YYYYMMDD') and
                                               end_date < to_date('20000101','YYYYMMDD')
               else
                   null
       end) order by employee_level;Thanks

    Hi,
    user469956 wrote:
    But all these examples have only one condition for each case.Depending on how you count, all WHERE clauses have only one condition.
    I see an example in that thread that has 6 atomic conditions, linked by AND and OR.
    I need to check date & code. This is what is causing the error.Why do you want to use a CASE statement?
    Why can't you put all your conditions directly iinto a WHERE clause, soemthing like this:
    WHERE   (   &class='SAP'
            AND code ='1'
    OR      (   start_date  > to_date('20000101','YYYYMMDD')
            AND end_date    < to_date('20000101','YYYYMMDD')
            )I said "something like this" because I don't know what you really want to do.

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

Maybe you are looking for

  • Chart not getting displayed with dimension having sorted

    hi Expers, we are facing some strange kind of problem... let me brief the details: 1. we have a column month no (from 1 to 12) and month name (Jan to dec). 2. our client need was to start month name from (Feb ,march.....dec,Jan). 3. we created a two

  • N80 How do you configure a dial up account?

    On my SE p800 I could create a dial up account as the equivalent of an Access Point on the N80. Is it possible to add a normal dial up internet account as an access point? or do you have to use WLAN or a pre defined access point such as 'O2 MobileWeb

  • Changing multiple sound clips volume?

    I need to adjust almost an entire track's sound (by about +5db...) Is there a simple way to select them all and apply +5db to multiple clips? Thanks!

  • Return posting to quality inspection stock

    Hi QM Gurus!        How can i post from unrestricted to quality insp stock? I am trying to use movement type 322(quality insp to unrestricted-reversal) and an error message says "Change the inspection stock of material 1101 in QM only". When i activa

  • Adobe Output Designer 5.7 or later Trail version

    Problem: Need to convert IFD file to XDP. Using Live Cycle Designer ES2 try to import the IFD file, following error occured "To import IFD, Adobe Output Designer 5.5 or later needs to be installed". Need Help: What is the current Version of Adobe Out