Collection in Where Clause

HI All,
can i use a collection in where clause?
In my PROCEDURE i am getting A collection VARIABLE of number as a In parameter and i want use that collection in where clause like
PROCEDURE GET_EMP_DETAILS(P_EMP_NO T_EMP_NO --COLLECTION VAARIABLE) IS
CURSOR C1
SELECT * FROM
EMPLOYEE
WHERE EMPNO IN P_EMP_NO;
BEGIN
END GET_EMP_DETAILS;
BUT THIS CODE IS GIVING ERROR
Error: PLS-00642: local collection types not allowed in SQL statements
Line: 439
Text: WHERE T.SOMH_SYS_ID IN P_T_OFFICE_MEMO_NO;
I AM USING ORACLE 10GR2.
THANKS IN ADAVNCE

using MEMBER OF can take 16 times longer than when we queried the collection with the TABLE operator.Maybe using submultiset performs better?
SQL> var x varchar2(10)
SQL> DECLARE
     col_tab      SYS.dbms_debug_vc2coll := sys.dbms_debug_vc2coll (1, 7788, 7900);
BEGIN
     SELECT COUNT ( * )
       INTO :x
       FROM emp
      WHERE sys.dbms_debug_vc2coll (empno) SUBMULTISET OF col_tab;
END;
PL/SQL procedure successfully completed.
SQL> print x
x        
2        

Similar Messages

  • Using collections in WHERE clause

    Hi friends,
    Please help me to use an associate array in SQL query (WHERE clause). The requirement is similar to the following example:
    ===============================================
    declare
    type rec_emp is record(emp_id integer, emp_name varchar2(100));
    type ty_emp is table of rec_emp index by pls_integer;
    tb_emp ty_emp;
    type ty_emp_history is table of emp_history%rowtype index by pls_integer;
    tb_emp_history ty_emp_history;
    begin
    select emp_id, emp_name
    bulk collect into tb_emp
    from emp
    where dept_id = 10;
    --Now I want to fetch records from emp_history based on the values in tb_emp. So I want a query something like the following.
    --(I know that join can be used to achive this. But it is just an example. I need to achive this in collections.)
    select *
    bulk collect into tb_emp_history
    from emp_history
    where emp_id = tb_emp.emp_id
    and emp_name = tb_emp.emp_name;
    end;
    ===============================================
    Thanks in advance.
    Edited by: Iniyavan on Oct 26, 2012 11:50 AM

    >
    Please help me to use an associate array in SQL query (WHERE clause).
    select *
    bulk collect into some_array
    >
    there is no variable 'some_array' in what you posted.
    If you want help with your code you have to post the code you are really using, not some hacked-up version of it that has errors.
    Here is sample code that shows how to treat a collection as a table using the TABLE operator
    -- type to match emp record
    create or replace type emp_scalar_type as object
      (EMPNO NUMBER(4) ,
       ENAME VARCHAR2(10),
       JOB VARCHAR2(9),
       MGR NUMBER(4),
       HIREDATE DATE,
       SAL NUMBER(7, 2),
       COMM NUMBER(7, 2),
       DEPTNO NUMBER(2)
    -- table of emp records
    create or replace type emp_table_type as table of emp_scalar_type
    declare
    tb emp_table_type;
    deptnoList sys.OdciNumberList;
    BEGIN
    select emp_scalar_type(empno, ename, job, mgr, hiredate, sal, comm, deptno)
    bulk collect into tb from emp;
    SELECT deptno bulk collect
    INTO deptnoList
    FROM dept where deptno not in (select deptno from table(tb));
    for i in 1..deptnoList.count loop
    dbms_output.put_Line(deptnoList(i));
    end loop;
    END;Note that tb is a collection and is useds in the subquery 'select deptno from table(tb)'.

  • How can I pass multiple condition in where clause with the join table?

    Hi:
    I need to collect several inputs at run time, and query the record according to the input.
    How can I pass multiple conditions in where clause with the join table?
    Thanks in advance for any help.
    Regards,
    TD

    If you are using SQL-Plus or Reports you can use lexical parameters like:
    SELECT * FROM emp &condition;
    When you run the query it will ask for value of condition and you can enter what every you want. Here is a really fun query:
    SELECT &columns FROM &tables &condition;
    But if you are using Forms. Then you have to change the condition by SET_BLOCK_PROPERTY.
    Best of luck!

  • Select multiple value in a where clause

    hello,
    im using developer 2000.
    suppose I have several values in a data grid. I want to use all of them in a where clause using IN operator or something. anybody knows how to do that. what I do is always insert all values in the grid into a temporary table and use that table in the where clause. is there any other easy, effective way of doing that?
    select *
    from table1
    where category in (-- I want to select multiple values form a data grid here--)
    thanks in advance.
    bonny.

    Hello Bonny,
    You might consider the use of PL/SQL Collection Types
    The first step in the process is to create a type and a table of that type.
    CREATE OR REPLACE TYPE DateType IS OBJECT ( Arg1 DATE );
    CREATE OR REPLACE TYPE TableList IS TABLE OF DateType;
    DECLARE
    list1 tablelist;
    BEGIN
    SELECT datetype (arg1)
    BULK COLLECT INTO list1
    FROM table1;
    FOR c1 IN (SELECT arg1
    FROM TABLE (CAST (list1 AS tablelist)))
    LOOP
    ---- Your code -----;
    END LOOP;
    END;
    For further insight please refer: http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96624/05_colls.htm
    Regards.

  • Sequence of tables in from clause and sequence of "where clause" conditions

    Is Sequence of tables in "From Clause" and sequence of "where clause" conditions matters in 10g for performance?
    Edited by: user6763079 on Jun 1, 2011 3:33 AM

    user6763079 wrote:
    Is Sequence of tables in "From Clause" and sequence of "where clause" conditions matters in 10g for performance?In general it does not matter.
    It could matter if the Rule Based Optimizer (RBO) is used. However this RBO is only used if enforced by a hint or if no table statistics are collected. Starting from 10g the table statistics are automatically selected by a regular database job. So in general the CBO would be used.
    The CBO will consider different access paths. If the number of tables is low enough, then all possible combinations are considered and the order does not make any difference.
    Edited by: Sven W. on Jun 1, 2011 4:00 PM

  • TopLink essentials: extra where clause for one to many relationship?

    We have a lot of tables that contain "historic" records. Those are marked by a column "historic" holding a value "Y". Sometimes we are not interested in historic values. For example in the next case:
    @Entity
    @Table(name="ART")
    public class Article {
        @OneToMany(mappedBy="article", cascade=CascadeType.ALL, fetch=FetchType.LAZY)
        private Collection<ArticleStats> arcItems;
        public Collection<ArticleStats> getArticleStats() {
            return arcItems;
    }One article can have multiple "stats". We are in this case only interested in the "stats" of this article that are not historic. In SQL terms, I would like to add an extra where clause: "WHERE historic = 'N'".
    Of course inheritance (with discriminators) is an option, but I don't prefer that. We have a lot of relationships like this and using inheritance would mean we have to add a lot of extra classes. Is there a way to add an extra where clause to the query that is used to retrieve all the stats records related tot my Article?
    We use TopLink essentials with an IBM AS/400 database.

    The JPA Spec does not handle this case, but TopLink Essentials does. You will need to customize your TopLink descriptor using a DescriptorCustomizer. You can set your DescriptorCustomizer in your persistence.xml using the "toplink.descriptor.customizer.<entity-name>" property set to the class name "<package>.<class>" of your customizer class.
    The customizer would look something like:
    public class MyCustomizer implements DescriptorCustomizer {
    public void customize(ClassDescriptor descriptor) {
    OneToManyMapping mapping = (OneToManyMapping )descriptor.getMappingForAttributeName("arcItems");
    ExpressionBuilder builder = new ExpressionBuilder();
    mapping.setSelectionCriteria(builder.getField("STAT.ART_ID").equal(builder.getParameter("ART.ID").and(builder.getField("HISTORY").equal("N")));
    If you never wanted historical records you could also add this expression to your descriptor's additionalJoinExpression.
    James Sutherland

  • Ref cursor argument in where clause

    Env: ORCL 9.2
    I have a func that uses the parameters in a where clause and returns a ref cursor as result. That works fine.
    I want to create an overloaded func that replaces one argument with a ref cursor. (instead of accepting a single value as an argument I want to accept multiple values) Can you specify the ref cursor in a where clause with out looping through the cursor ?
    CURRENT
    func(arg1,arg2,arg3) returns ref cursor
    is
    select blah from sometable s
    where s.a = arg1
    and s.b = arg2
    and s.c = arg3
    NEW
    func(ref_cur_arg1,arg2,arg3) returns ref cursor
    is
    select blah from sometable s
    where s.a = ref_cur_arg1
    and s.b = arg2
    and s.c = arg3
    is there something like:
    where s.a in (loop fetch ref_cur_arg1 end loop)
    thx

    Thanks Rich,
    That's pretty much what I came up with:
    FUNCTION f_bond_price_w_bb_stat (
                                  p_id_ref gtyp_instr_id_ref,
                                  p_price_srce bond_price.PRICE_SRCE%type,
                                  p_price_type bond_price.PRICE_TYPE%type,
                                  p_price_date bond_price.PRICE_DATE%type)
    RETURN gtyp_bondprice_w_bb_stat_rfc
    IS
    lv_bondprice_rfc gtyp_bondprice_w_bb_stat_rfc;
    TYPE ARRAY1 IS TABLE OF instr_ext_id_map.ext_id_value%TYPE INDEX BY BINARY_INTEGER;
    t_instr_id ARRAY1;
    instr_ids INSTR_EXT_ID_T := INSTR_EXT_ID_T();
    BEGIN
         --suck the contents of the ref cursor into a local virtual tmp table
    FETCH p_id_ref BULK COLLECT INTO t_instr_id;
    FOR i IN 1..t_instr_id.COUNT LOOP
         instr_ids.extend;
              instr_ids(instr_ids.count) := t_instr_id(i);
    END LOOP;
    CLOSE p_id_ref;
    OPEN lv_bondprice_rfc FOR
    SELECT
    bs.ID_ISIN,
    bs.TICKER,
    bs.CPN,
    bs.MATURITY,
    round(months_between(bs.MATURITY,sysdate)/12,1),
    bs.ISSUER_INDUSTRY,
    bs.INDUSTRY_SECTOR,
    FROM bond_price b,
    instr_ext_id_map ext,
    etl.mdy_ratingstatic mrs,
         etl.mdy_extid mxid,
         etl.bloomberg_static bs
    WHERE b.INSTR_ID = ext.instr_id
    AND bs.ID_ISIN(+) = ext.ext_id_value
    AND bs.ID_ISIN = mxid.EXTIDVALUE(+)
    AND mrs.MOODYDEBTNUM(+) = mxid.MOODYDEBTNUM
    AND ext.ext_id_value in (select * from TABLE (cast (instr_ids AS INSTR_EXT_ID_T) ))
    AND b.PRICE_SRCE = p_price_srce
    AND b.PRICE_TYPE = p_price_type
    AND b.PRICE_DATE = p_price_date
    RETURN lv_bondprice_rfc;
    END f_bond_price_w_bb_stat;

  • DYNAMIC WHERE CLAUSE in PROCEDURE

    I am trying to pass in the IN portion of the where clause to an update statement within a procedure and it is not updating any rows. I want to update 2 columns where the ID's are in the string of ID's I am passing in.
    PROCEDURE upd_corebio
    (p_dup_string     IN          VARCHAR2,
    p_source     IN          VARCHAR2,
    p_title          IN          VARCHAR2)
    IS
    BEGIN
    UPDATE corebio
    SET corettlbar = p_title, coresource = p_source
    WHERE coreid IN (p_dup_string);
    END upd_corebio;
    upd_corebio('1001,2002,3003','SOURCE','TITLE')
    FYI...COREID IS CHAR(10)
    CORETTLBAR IS CHAR(30)
    CORESOURCE IS CHAR(6)

    The rownum hint seems to work on my system (Windows, 9.2.0.1)
    First, we'll set up the objects
    create table collection_test (
      col1 NUMBER,
      col2 VARCHAR2(100)
    create sequence coll_seq
      start with 1
      increment by 1
      cache 100;
    begin
      for x in (select * from all_objects)
      loop
        insert into collection_test
          values( coll_seq.nextval, x.object_name );
      end loop;
    end;
    create unique index coll_test_idx
      on collection_test( col1 );
    analyze index coll_test_idx compute statistics
    analyze table collection_test compute statistics;Now, try with the "generic" approach, with the CARDINALITY hint, which won't work, and the rownum trick, which appears to work
    SQL> ed
    Wrote file afiedt.buf
      1  SELECT *
      2    FROM collection_test
      3*  WHERE col1 IN (SELECT * FROM TABLE(CAST(f_number_table('1,2,3') as numberTable)))
    SQL> /
          COL1
    COL2
             1
    /1005bd30_LnkdConstant
             2
    /10076b23_OraCustomDatumClosur
             3
    /10297c91_SAXAttrList
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=297327 Card=1 Bytes=
              28)
       1    0   NESTED LOOPS (SEMI) (Cost=297327 Card=1 Bytes=28)
       2    1     TABLE ACCESS (FULL) OF 'COLLECTION_TEST' (Cost=19 Card=2
              7028 Bytes=756784)
       3    1     COLLECTION ITERATOR (PICKLER FETCH) OF 'F_NUMBER_TABLE'
    Statistics
            687  recursive calls
              0  db block gets
            331  consistent gets
              6  physical reads
             68  redo size
            546  bytes sent via SQL*Net to client
            503  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
             19  sorts (memory)
              0  sorts (disk)
              3  rows processed
    SQL> ed
    Wrote file afiedt.buf
      1  SELECT *
      2    FROM collection_test
      3*  WHERE col1 IN (SELECT /*+ CARDINALITY(t 10) */ * FROM TABLE(CAST(f_number_table('1,2,3') as nu
    SQL> /
          COL1
    COL2
             1
    /1005bd30_LnkdConstant
             2
    /10076b23_OraCustomDatumClosur
             3
    /10297c91_SAXAttrList
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=297327 Card=1 Bytes=
              28)
       1    0   NESTED LOOPS (SEMI) (Cost=297327 Card=1 Bytes=28)
       2    1     TABLE ACCESS (FULL) OF 'COLLECTION_TEST' (Cost=19 Card=2
              7028 Bytes=756784)
       3    1     COLLECTION ITERATOR (PICKLER FETCH) OF 'F_NUMBER_TABLE'
    Statistics
              0  recursive calls
              0  db block gets
            177  consistent gets
              0  physical reads
              0  redo size
            546  bytes sent via SQL*Net to client
            503  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              3  rows processed
    SQL> ed
    Wrote file afiedt.buf
      1  SELECT *
      2    FROM collection_test
      3*  WHERE col1 IN (SELECT /*+ CARDINALITY(t 10) */ * FROM TABLE(CAST(f_number_table('1,2,3') as nu
    SQL> /
          COL1
    COL2
             1
    /1005bd30_LnkdConstant
             2
    /10076b23_OraCustomDatumClosur
             3
    /10297c91_SAXAttrList
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=23 Card=10 Bytes=410
       1    0   NESTED LOOPS (Cost=23 Card=10 Bytes=410)
       2    1     VIEW OF 'VW_NSO_1' (Cost=11 Card=10 Bytes=130)
       3    2       SORT (UNIQUE)
       4    3         COUNT
       5    4           FILTER
       6    5             COLLECTION ITERATOR (PICKLER FETCH) OF 'F_NUMBER
              _TABLE'
       7    1     TABLE ACCESS (BY INDEX ROWID) OF 'COLLECTION_TEST' (Cost
              =1 Card=1 Bytes=28)
       8    7       INDEX (UNIQUE SCAN) OF 'COLL_TEST_IDX' (UNIQUE)
    Statistics
              0  recursive calls
              0  db block gets
             14  consistent gets
              0  physical reads
              0  redo size
            546  bytes sent via SQL*Net to client
            503  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
              3  rows processedUnless I'm missing the boat, it seems like the last approach is using the more appropriate index access path.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • EJB-QL how to write "IN" in where clause?

    I have a table containing a few entities which have a status. I would like to know how I can write a query to retrieve all the objects with their status set to specific values that I would provide as a Collection parameter.
    Something like this:
    the query: "select o from MyEntity o where o.status IN :statuses"
    and then em.createNamedQuery(theQuery).setParameter("statuses", aCollectionOfStatuses) where 'aCollectionOfStatuses' is a java.util.Collection<String>. Is this possible? Or the only lousy solution is to create a new query where I build the where clause dynamically by concatenating a bunch of OR-linked conditions?
    Edited by: user8887188 on 18-Oct-2010 05:08

    If you are using hibernate then passing the String collection to the in clause should work.
    The other more guaranteed solution is to write a helper method that generates the IN clause SQL string for you.

  • Array in Where Clause

    Hi,
    I am having a function with an IN paramter as an array.
    How do i use all the values in this array in the Where clause?
    Function ( tArrayOfNos IN tArrType )
    open Tstcursor FOR
    select     ...
    from     ...
    where tNo in <all the nos in the array tArrayOfNos >
    thanks for your help..

    >
    If i define the type inside my package and try to use the Member Of in a function, it doesn't work..
    >
    In the examples above you will need to have a type declared in the database, however you can create a pipelined function... something like this,
    SQL> CREATE OR REPLACE Package My_Types Is
      2 
      3     Type enames_tab Is Table Of Varchar2(50);
      4 
      5  End My_Types;
      6  /
    Package created
    SQL> CREATE OR REPLACE Function lookup_ename Return my_types.enames_tab
      2     Pipelined Is
      3     v_row   my_types.enames_tab;
      4     cur     Sys_Refcursor;
      5     v_ename Varchar2(50);
      6  Begin
      7     v_row := my_types.enames_tab();
      8     Open cur For
      9        SELECT ename
    10          FROM emp
    11         WHERE ename IN ('SMITH', 'JAMES', 'WARD');
    12     Loop
    13        Fetch cur
    14           INTO v_ename;
    15        Exit When cur%Notfound;
    16        v_row.Extend;
    17        v_row(v_row.Count) := v_ename;
    18        Pipe Row(v_row(v_row.Count));
    19     End Loop;
    20     Return;
    21  End;
    22  /
    Function created
    SQL> Set Serveroutput on;
    SQL> Declare
      2     v_tab my_types.enames_tab;
      3  Begin
      4     SELECT ename Bulk Collect
      5       INTO v_tab
      6       FROM emp
      7      WHERE ename Member Of lookup_ename;
      8 
      9     For i IN v_tab.First .. v_tab.Last Loop
    10        dbms_output.put_line(v_tab(I));
    11     End Loop;
    12  End;
    13  /
    SMITH
    WARD
    JAMES
    PL/SQL procedure successfully completed

  • ROWID in Where clause

    Hello All,
    I have table with 25 columns.
    First three columns are composite keys
    1. ID, . STORE_NUM, 3. STORE_NUM_WEEK
    to update data i have to use all three column in WHERE clause for proper update. So in cursor also i have to select all three rows., Instead i SELECTED ROWID in cursor and used in where caluse in BULK COLLECT and FORALL update. instead of fetching all three rows. IS this the correct approch. WIth ROWID in don't have to use HINTs and the query and updation runs faster then the other( without ROWID).
    I was reading on the intenet some where that using ROWID in not advisible in query.
    How correct it is in my case.
    Please clearify my daughts.
    Thank you in Advance

    Thank you sundar for your response.
    Please look at my procedure. as under . I am posting the same for your consideration. It is updating selective rows only not all rows. As suggested. How can I do in SQL what about the formula to calculate the value to update.
    Please ignore the syntex but look ate code and if you have any suggestion.Sorry for BIG CODE Procedure SP_930_End_Of_Week_OH_up (
                pSKU                       In SS_SKU_Store_Week.SKU%Type,
                pStore                     In SS_SKU_Store_Week.Store_Num%Type)
    Is
      Type  tOnHand               is table of            SS_SKU_Store_Week.End_Of_Week_On_Hand%Type;
    Type  tPlannedReceipts      is table of           SS_SKU_Store_Week.Planned_Receipts%Type;
    Type  tShipmentQuantity     is table of          SS_SKU_Store_Week.Shipment_Quantity%Type;
    Type  tWarehouseAllocation  is table of          SS_SKU_Store_Week.Warehouse_Allocation%Type;
    Type  tPlannedSalesTW       is table of          SS_SKU_Store_Week.Distributed_Planned_Sales%Type;
    Type  tPlannedWeekFlag      is table of          SS_SKU_Store_Week.Planned_Week_Flag%Type;
    Type  tOpertunityRating     is table of         SS_SKU_Store_Week.OPPORTUNITY_RATING%type;
    Type  tLastWeekEndOfWeekOnHand  is table of     number index by binary_integer;
    Type  tEndOfWeekOnHand      is table of         number index by binary_integer;
    Type tRowid                  Is Table Of        ROWID Index By Binary_Integer;
      -- vYearWeekKey               tYearWeekKey;
       vOnHand                    tOnHand;
       vPlannedReceipts           tPlannedReceipts;
       vShipmentQuantity          tShipmentQuantity ;
       vWarehouseAllocation       tWarehouseAllocation;
       vPlannedSalesTW            tPlannedSalesTW;
       vPlannedWeekFlag           tPlannedWeekFlag;
       vLastWeekEndOfWeekOnHand   tLastWeekEndOfWeekOnHand;
       v_total_EndOfWeekOnHand     tEndOfWeekOnHand;
       vOpertunityRating           tOpertunityRating;
       vdistributedSales           tPlannedSalesTW;  -- distributed planned sales
       vOpRat                      tEndOfWeekOnHand;
       vRowId                      tRowId;
       vRowId_1                    tRowId;
       vEndOfWeekOnHand            Number;
       vFirstWeek                  Boolean;
       vForwardSales               Number;
       v_idx pls_integer;
      CURSOR OpportunityRating_Cursor Is
          SELECT   Opportunity_Rating,
                   End_Of_Week_On_Hand,
                   Decode(PSW_Flag, 0, 0, Distributed_Planned_Sales)  
                 DistributedPlannedSales,
                   ROWID
          FROM     SS_SKU_Store_Week
          WHERE    SKU                  = pSKU AND
                   Store_Num            = pStore
          ORDER BY Year_Week_Key Desc;
         --FOR UPDATE;
      Cursor EOWOH_Cursor is
          SELECT  Floor(Starting_On_Hand * On_Hand_Percent) + Contributing_On_Hand        OnHand,
                  (Planned_Receipts * On_Order_Flag) + Contributing_On_Order     PlannedReceipts,
                  Nvl(Shipment_Quantity, 0)                                     ShipmentQuantity,
                  Decode(PSW_Flag, 0, 0, Distributed_Planned_Sales)      DistributedPlannedSales,
                  Warehouse_Allocation, SS_SKU_Store_Week.ROWID
          FROM    SS_SKU,
                  SS_SKU_Store,
                  SS_SKU_Store_Week
          WHERE   SS_SKU.SKU                 = pSKU AND
                  SS_SKU.SKU                 = SS_SKU_store.SKU AND
                  SS_SKU_Store.Store_Num     = pStore  AND
                  SS_SKU_Store.SKU           = SS_SKU_Store_Week.SKU AND
                  SS_SKU_Store.Store_Num     = SS_SKU_Store_Week.Store_Num
          ORDER BY Year_Week_Key;
    Begin
       vFirstWeek := True;
        Open EOWOH_Cursor;
         Loop
             FETCH    EOWOH_Cursor bulk collect
              INTO     vOnHand,
                       vPlannedReceipts,
                       vShipmentQuantity,
                       vPlannedSalesTW,
                       vWarehouseAllocation,
                       vRowID limit 100;
            for i in 1..vRowId.count loop
                  begin
                       If vFirstWeek Then
    vFirstWeek := False;
    vLastWeekEndOfWeekOnHand(i) := vOnHand(i);
    ElsIf vEndOfWeekOnHand > 0 Then
    vLastWeekEndOfWeekOnHand(i) :=vEndOfWeekOnHand;
    Else
    vLastWeekEndOfWeekOnHand(i) := 0;
    End If;
    vEndOfWeekOnHand := vLastWeekEndOfWeekOnHand(i)
    + vPlannedReceipts(i)
    + vShipmentQuantity(i)
    + vWarehouseAllocation(i)
    - vPlannedSalesTW(i);
    v_total_EndOfWeekOnHand(i):=vEndOfWeekOnHand;
    exception
    when others then
    null;
    end;
            End loop;
             forall i in 1..vRowId.count
                           UPDATE   SS_SKU_Store_Week
                           SET      End_Of_Week_On_Hand     =
           v_total_EndOfWeekOnHand(i)
                           WHERE    ROWID= vRowId(i);
               Exit When EOWOH_Cursor%NotFound;
       End Loop;
        close EOWOH_Cursor;
        Commit;
       vForwardSales := 0;
       v_idx :=1;
       vRowId.delete;
       vOnHand.delete;
       OPEN OpportunityRating_Cursor;
       LOOP
            FETCH OpportunityRating_Cursor bulk collect into
                      vOpertunityRating,vOnHand, vdistributedSales,
                      vRowId limit 100;
               FOR i in   1..vRowId.count  LOOP
                     IF  vOpertunityRating(i) Is Not Null Then
                           vOpRat(v_idx):=case  vforwardsales
                                          when 0 then 1
                                          else  Round(vOnHand(i)/ vForwardSales, 4)
                                                                     end;
                              vRowId_1(v_idx)    :=vRowId(i);
                              v_idx                :=v_idx+1;
                              vForwardSales := 0;
                      END IF;
    vForwardSales := vForwardSales + vdistributedSales(i);
               END LOOP;
               FORALL i in 1..vRowId_1.count
                     update  SS_SKU_Store_Week
                      SET  Opportunity_Rating      = vOpRat(i)
                      Where           ROWID= vRowId_1(i);
                EXIT WHEN OpportunityRating_Cursor%NOTFOUND;
       END LOOP;
          CLOSE OpportunityRating_Cursor;
         COMMIT;
    Exception
       When OTHERS Then
          Null;
    End SP_930_End_Of_Week_OH_up;
    Do you have suggestion.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Expenditure Type LOV-- Adding where clause with controller extension- help

    Hi Gurus,
    I'm new to OA Framework and Java and I need to extend the controller for the expenditure type lov in iProcurement. I need to add a where clause to the VO to show only those expenditure
    types that will pass transactions controls based on the project and task.
    Name of the VO:ExpenditureTypeNoAwardLOVVO
    controller:oracle.apps.icx.lov.webui.ExpenditureTypeLovCO
    Original Query from the VO:
    select * from (SELECT et.expenditure_type, et.sys_link_start_date_active,
    et.sys_link_end_date_active, 1 as dummy_number
    FROM pa_expenditure_types_expend_v et
    WHERE et.system_linkage_function = 'VI'
    and (trunc(sysdate) between et.expnd_typ_start_date_active and
    nvl(et.expnd_typ_end_date_active, trunc(sysdate+1)))
    and (trunc(sysdate) between et.sys_link_start_date_active and
    nvl(et.sys_link_end_date_active, trunc(sysdate+1))) QRSLT
    ((WHERE UPPER(EXPENDITURE_TYPE) like UPPER(:1)
    AND (UPPER(EXPENDITURE_TYPE) like :2 or UPPER(EXPENDITURE_TYPE) like :3
    or UPPER(EXPENDITURE_TYPE) like :4 or UPPER(EXPENDITURE_TYPE) like :5)))
    I created a custom database function xxpa_check_txnctl which takes project_id, task_id and expenditure type as parameters and returns "Y" if that expenditure type is valid or
    returns "N" if it is not valid.
    What I need to add to the where clause of the above query is
    and *'Y' = ( select xxpa_check_txnctl(project_id,task_id,et.expenditure_type) from dual)* to the standard VO query so that only valid expenditure types will show up in the LOV for that
    project/task combination.
    I enabled the Debug Log from Diagnostics and able to see the values of project_id and task_id in the controller attached to the LOV (oracle.apps.icx.lov.webui.ExpenditureTypeLovCO) as shown
    below. Please tell me how I can add the where condition to the custom controller .
    I really appreciate your help.
    Thanks in Advance,
    Shree.
    ==========================================================================================
    [28]:STATEMENT:[icx.lov.webui.ExpenditureTypeLovCO]:#Param# ProjectId=13
    [28]:STATEMENT:[icx.lov.webui.ExpenditureTypeLovCO]:lov criteria item from dictionary in getLovItemNumber():
    [28]:STATEMENT:[icx.lov.webui.ExpenditureTypeLovCO]:#Param# TaskId=796
    [28]:STATEMENT:[icx.lov.webui.ExpenditureTypeLovCO]:VO used in ExpenditureTypeLovCO.java:
    [28]:STATEMENT:[icx.lov.webui.ExpenditureTypeLovCO]:#Param# voName=ExpenditureTypeNoAwardLovVO
    ==========================================================================================
    Here is the code for the standard controller:
    ==========================================================================================
    package oracle.apps.icx.lov.webui;
    import com.sun.java.util.collections.ArrayList;
    import oracle.apps.fnd.common.VersionInfo;
    import oracle.apps.fnd.framework.OAApplicationModule;
    import oracle.apps.fnd.framework.OAViewObject;
    import oracle.apps.fnd.framework.webui.OAPageContext;
    import oracle.apps.fnd.framework.webui.beans.OAWebBean;
    import oracle.apps.fnd.framework.webui.beans.form.OAFormValueBean;
    import oracle.apps.fnd.framework.webui.beans.layout.OAListOfValuesBean;
    import oracle.apps.fnd.framework.webui.beans.message.OAMessageStyledTextBean;
    import oracle.apps.icx.por.req.webui.CheckoutInfoBaseCO;
    import oracle.jbo.domain.Number;
    public class ExpenditureTypeLovCO extends CheckoutInfoBaseCO
    public static final String RCS_ID = "$Header: ExpenditureTypeLovCO.java 120.1 2006/07/25 06:33:16 sudsubra noship $";
    public static final boolean RCS_ID_RECORDED = VersionInfo.recordClassVersion("$Header: ExpenditureTypeLovCO.java 120.1 2006/07/25 06:33:16 sudsubra noship $",
    "oracle.apps.icx.lov.webui");
    public ExpenditureTypeLovCO()
    public void processRequest(OAPageContext oapagecontext, OAWebBean oawebbean)
    super.processRequest(oapagecontext, oawebbean);
    java.util.Dictionary dictionary = oapagecontext.getLovCriteriaItems();
    Number number = getLovItemNumber(oapagecontext, dictionary, "ReqAwardId");
    Number number1 = getLovItemNumber(oapagecontext, dictionary, "ProjectId");
    Number number2 = getLovItemNumber(oapagecontext, dictionary, "TaskId");
    String s = null;
    if(number == null)
    s = "ExpenditureTypeNoAwardLovVO";
    } else
    ArrayList arraylist = new ArrayList(1);
    arraylist.add("getDefaultAwardId");
    Number number3 = (Number)executeServerCommand(oapagecontext, oapagecontext.getApplicationModule(oawebbean), "CheckoutLovSvrCmd", arraylist);
    if(isLoggingEnabled(oapagecontext, 1))
    logParam(this, oapagecontext, "defaultAwardId", number3, 1);
    if(number.equals(number3))
    s = "ExpenditureTypeWithDefaultAwardLovVO";
    OAViewObject oaviewobject = (OAViewObject)oapagecontext.getApplicationModule(oawebbean).findViewObject("ExpenditureTypeWithDefaultAwardLovVO");
    oaviewobject.setWhereClauseParam(0, number1);
    oaviewobject.setWhereClauseParam(1, number2);
    } else
    s = "ExpenditureTypeWithAwardLovVO";
    OAViewObject oaviewobject1 = (OAViewObject)oapagecontext.getApplicationModule(oawebbean).findViewObject("ExpenditureTypeWithAwardLovVO");
    oaviewobject1.setWhereClauseParam(0, number);
    if(isLoggingEnabled(oapagecontext, 1))
    logMsg(this, oapagecontext, "VO used in ExpenditureTypeLovCO.java:", 1);
    logParam(this, oapagecontext, "voName", s, 1);
    OAMessageStyledTextBean oamessagestyledtextbean = (OAMessageStyledTextBean)oawebbean.findIndexedChildRecursive("ExpenditureType");
    oamessagestyledtextbean.setViewUsageName(s);
    OAMessageStyledTextBean oamessagestyledtextbean1 = (OAMessageStyledTextBean)oawebbean.findIndexedChildRecursive("StartDate");
    oamessagestyledtextbean1.setViewUsageName(s);
    OAMessageStyledTextBean oamessagestyledtextbean2 = (OAMessageStyledTextBean)oawebbean.findIndexedChildRecursive("EndDate");
    oamessagestyledtextbean2.setViewUsageName(s);
    OAFormValueBean oaformvaluebean = (OAFormValueBean)oawebbean.findIndexedChildRecursive("ReqAwardId");
    oaformvaluebean.setViewUsageName(s);
    OAFormValueBean oaformvaluebean1 = (OAFormValueBean)oawebbean.findIndexedChildRecursive("ProjectId");
    oaformvaluebean1.setViewUsageName(s);
    OAFormValueBean oaformvaluebean2 = (OAFormValueBean)oawebbean.findIndexedChildRecursive("TaskId");
    oaformvaluebean2.setViewUsageName(s);
    ((OAListOfValuesBean)oawebbean).setViewUsageName(s);
    public void processFormRequest(OAPageContext oapagecontext, OAWebBean oawebbean)
    super.processFormRequest(oapagecontext, oawebbean);
    ==========================================================================================

    Hi, I will try to look into the issue. I have also done customizations like this in past.
    To achieve this, we must read the Process request of CO properly and understand the places, where you have to make changes. In my case, I identify such places and also I couldn't extend the controller class. SO I took the code from standard CO, changed it at couple of places and created a class file with same code as standard CO but with changed at some places. After that I gave newly created CO name in personalization property, so that the page will follow newly created custom CO.
    So I would suggest to read the CO properly, to understand which line is doing what......

  • Filter Records in WHERE clause iReports using values passed from a prgram

    I have searched for iReports manual and what i can see are docs on sale. I have managed to create jrxml file, execute it in jsp and actually view the report.
    Now i have a big list of customers from various branches and have various categories. I would like to know how to pass the parameters so that i retrieve a small list of items. e.g. WHERE cu.branch=200 AND cu.category=10. That is i would like to pass 20 and 10 to the jrxml query stored.
    In iReports i saw parameters, variables and fields but it seems like these are displayable fields.
    How will i achieve this. Am seeking for assistance.
    null

    >
    Please help me to use an associate array in SQL query (WHERE clause).
    select *
    bulk collect into some_array
    >
    there is no variable 'some_array' in what you posted.
    If you want help with your code you have to post the code you are really using, not some hacked-up version of it that has errors.
    Here is sample code that shows how to treat a collection as a table using the TABLE operator
    -- type to match emp record
    create or replace type emp_scalar_type as object
      (EMPNO NUMBER(4) ,
       ENAME VARCHAR2(10),
       JOB VARCHAR2(9),
       MGR NUMBER(4),
       HIREDATE DATE,
       SAL NUMBER(7, 2),
       COMM NUMBER(7, 2),
       DEPTNO NUMBER(2)
    -- table of emp records
    create or replace type emp_table_type as table of emp_scalar_type
    declare
    tb emp_table_type;
    deptnoList sys.OdciNumberList;
    BEGIN
    select emp_scalar_type(empno, ename, job, mgr, hiredate, sal, comm, deptno)
    bulk collect into tb from emp;
    SELECT deptno bulk collect
    INTO deptnoList
    FROM dept where deptno not in (select deptno from table(tb));
    for i in 1..deptnoList.count loop
    dbms_output.put_Line(deptnoList(i));
    end loop;
    END;Note that tb is a collection and is useds in the subquery 'select deptno from table(tb)'.

  • Derive found flag in SQL with where clause using TABLE(CAST function

    Dear All,
    Stored procedure listEmployees
    ==========================
    CREATE OR REPLACE TYPE STRING_ARRAY AS VARRAY(8000) OF VARCHAR2(15);
    empIdList STRING_ARRAY
    countriesList STRING_ARRAY
    SELECT EMP_ID, EMP_COUNTRY, EMP_NAME, FOUND_FLAG_
    FROM EMPLOYEE WHERE
    EMP_ID IN
    (SELECT * FROM TABLE(CAST(empIdList AS STRING_ARRAY))
    AND EMP_COUNTRY IN
    (SELECT * FROM TABLE(CAST(countriesList AS STRING_ARRAY))
    =================
    I have a stored procedure which lists the employees using above simple query.
    Here I am using table CAST function to find the list of employees in one go
    instead of looping through each and every employee
    Everything fine until requirements forced me to get the FOUND_FLAG as well.
    Now I wanted derive the FOUND_FLAG by using rownum, rowid, decode functions
    but I was not successful
    Can you please suggest if there is any intelligent way to say weather the
    row is found for given parameters in the where clause?
    If not I may have to loop through each set of empIdList, countriesList
    and find the values individually just to set a flag. In this approach I can’t use
    the TABLE CAST function which is efficient I suppose.
    Note that query STRING_ARRAY is an VARRAY. It is very big in size and this procedure
    suppose to handle large sets of data.
    Thanks In advance
    Regards
    Charan
    Edited by: kmcharan on 03-Dec-2009 09:55
    Edited by: kmcharan on 03-Dec-2009 09:55

    If your query returns results, you have found them... so your "FOUND" flag might be a constant,...

  • Index usage in depending on where clause changes.

    Hello Friends,
    I need your help for one issue.
    I have one query , which is using two table Say T1 and T2, where C1 is common column using which both are joined.
    C1 is primary key in T1, but no index available in T2 for C1. T1C2 is the column which we want to select.
    (Note that Either of table can be a Master table)
    Now see the query:
    Select T1C2
    From T1, T2
    where T2.C1 = T1.C1
    Here where clause may have other conditions and From clause may have others tables as per requirements.
    I want to know that, if, I change the query like following to let my query use the available index of T1.C1.
    Select T1C2
    from T1, T2
    where T1.C1 = T2.C1
    Then, Will the query use the available index of T1. and Will i get better performance. Even a little improvement in performance may help me a lot as this kind of query is being used within a where loop (so it is going to be executed multiple times).
    Please advise on this..
    Regards,
    Dipali..

    Hi,
    18:43:17 rel15_real_p>create table t1(c1 number primary key, c2 number);
    Table created.
    18:43:26 rel15_real_p>create table t2(c1 number, c2 number);
    18:45:08 rel15_real_p>
    18:45:09 rel15_real_p>begin
    18:45:09   2  for i in 1..100
    18:45:09   3  loop
    18:45:09   4        insert into t1(c1,c2) values (i,i+100);
    18:45:09   5  end loop;
    18:45:09   6  commit;
    18:45:09   7  end;
    18:45:09   8  /
    PL/SQL procedure successfully completed.
    18:45:09 rel15_real_p>
    18:45:09 rel15_real_p>
    18:45:09 rel15_real_p>begin
    18:45:09   2  for i in 1..100
    18:45:09   3  loop
    18:45:09   4        insert into t2(c1,c2) values (i,i+200);
    18:45:09   5  end loop;
    18:45:09   6  commit;
    18:45:09   7  end;
    18:45:09   8  /
    18:45:23 rel15_real_p>select count(*) from t1;
      COUNT(*)
           100
    18:45:30 rel15_real_p>select count(*) from t2;
      COUNT(*)
           100
    18:45:49 rel15_real_p>select index_name,index_type from user_indexes where table
    _name='T1';
    INDEX_NAME                     INDEX_TYPE
    SYS_C0013059                   NORMAL
    18:48:21 rel15_real_p>set autotrace on
    18:52:25 rel15_real_p>Select T1.C2
    18:52:29   2  From T1, T2
    18:52:29   3  where T2.C1 = T1.C1
    18:52:29   4  /
            C2
           101
           102
           103
           104
           105
            C2
           200
    100 rows selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=7 Card=100 Bytes=
              900)
       1    0   HASH JOIN (Cost=7 Card=100 Bytes=3900)
       2    1     TABLE ACCESS (FULL) OF 'T1' (TABLE) (Cost=3 Card=100 By
              es=2600)
       3    1     TABLE ACCESS (FULL) OF 'T2' (TABLE) (Cost=3 Card=100 By
              es=1300)
    Statistics
              0  recursive calls
              0  db block gets
             21  consistent gets
              0  physical reads
              0  redo size
           1393  bytes sent via SQL*Net to client
            562  bytes received via SQL*Net from client
              8  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
            100  rows processed
    18:52:31 rel15_real_p>analyze table t1 compute statistics;
    Table analyzed.
    18:55:35 rel15_real_p>analyze table t2 compute statistics;
    18:55:38 rel15_real_p>set autotrace on
    18:55:42 rel15_real_p>Select T1.C2
    18:55:43   2  From T1, T2
    18:55:45   3  where T2.C1 = T1.C1
    18:55:46   4  /
            C2
           101
           102
           103
           104
           105
            C2
           200
    100 rows selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=6 Card=100 Bytes=7
              00)
       1    0   MERGE JOIN (Cost=6 Card=100 Bytes=700)
       2    1     TABLE ACCESS (BY INDEX ROWID) OF 'T1' (TABLE) (Cost=2 Ca
              rd=100 Bytes=500)
       3    2       INDEX (FULL SCAN) OF 'SYS_C0013059' (INDEX (UNIQUE)) (
              Cost=1 Card=100)
       4    1     SORT (JOIN) (Cost=4 Card=100 Bytes=200)
       5    4       TABLE ACCESS (FULL) OF 'T2' (TABLE) (Cost=3 Card=100 B
              ytes=200)
    Statistics
              1  recursive calls
              0  db block gets
             23  consistent gets
              0  physical reads
              0  redo size
           1393  bytes sent via SQL*Net to client
            562  bytes received via SQL*Net from client
              8  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
            100  rows processed
    18:56:56 rel15_real_p>Select T1.C2
    18:56:56   2  From T1, T2
    18:56:56   3  where T1.C1 = T2.C1
    18:56:58   4  /
            C2
           101
           102
           103
           104
           105
            C2
           200
    100 rows selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=6 Card=100 Bytes=7
              00)
       1    0   MERGE JOIN (Cost=6 Card=100 Bytes=700)
       2    1     TABLE ACCESS (BY INDEX ROWID) OF 'T1' (TABLE) (Cost=2 Ca
              rd=100 Bytes=500)
       3    2       INDEX (FULL SCAN) OF 'SYS_C0013059' (INDEX (UNIQUE)) (
              Cost=1 Card=100)
       4    1     SORT (JOIN) (Cost=4 Card=100 Bytes=200)
       5    4       TABLE ACCESS (FULL) OF 'T2' (TABLE) (Cost=3 Card=100 B
              ytes=200)
    Statistics
              1  recursive calls
              0  db block gets
             23  consistent gets
              0  physical reads
              0  redo size
           1393  bytes sent via SQL*Net to client
            562  bytes received via SQL*Net from client
              8  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
            100  rows processed- Pavan Kumar N

Maybe you are looking for

  • Im Trying To Learn Java :o(

    Hey All, I have decided to get my mind active and randomly learn Java. I say randomly because i am going to be a student again in IT but i like the kinda 3D side and modelling and nice pictures and flash actionscript lol not all this stuff. Anways i

  • IMPORT/EXPORT statement in Background Mode

    Hey dudes, I am facing a problem in my coding. I am dealing with coding in several events in IS-U, transaction FPY1. However, it's not so important ya. Now I am written some code on IMPORT and EXPORT some parameters between 2 program code. It's work

  • Oracle Wireless Development

    I have to develop a 3 tier application using O9iAS WE as application server and Oracle 9i as database to access all the details invloved in a big hospital through PCs and Pocket PCs (Wirelessly). I have to decide between Oracle forms developer and Or

  • Entourage 2008 full day events displayed on the wrong day

    Hi I am using Entourage 2008 with an exchange server and a blackberry. As well I have a Windows notebook with MS Outlook. My problem is: If I setup a full day event it will be displayed correct on my outlook and my blackberry BUT entourage will show

  • Installing Logic Pro 7.2 on my MacBook Pro

    I need to install Logic Pro 7.2 on my laptop. I originally purchased Logic Pro 6 and then bought the upgrade to Logic Pro 7. So my question is do I need to install 6 then do the upgrade to 7? I have an intel Mac Book Pro 17'. Will I have any issues i