Using multiple values in a where clause, for values only known at runtime

Dear all
I am creating a PL/SQL program which returns multiple rows of data but only where it meets a set id values that a user has previously chosen. The id values are stored in an associative array and are chosen by a user in the preceding procedure at run time.
I know all the table and column names in advance. The only things I don't know are the exact number of ids selected from the id column and what their values will be. This will only be known at runtime. When the procedure is run by the user it prints multiple rows of data to a web browser.
I have been reading the following posting, which I understand to a large extent, Query for multiple value search But I cannot seem to figure out how I would apply it to my work as I am dealing with multiple rows and a cursor.
The code as I have currently written it is wrong because I get an error not found message in my web browser. I think the var_user_chosen_map_list_ids in the for cursor loop could be the problem. I am using the variable_user_chosen_map_list_ids to store all the id values from my associatative array as a string. Which I modified from the code that vidyadhars posted in the other thread.
Should I be creating a OPEN FOR ref cursor and if so where would I put my associative array into it? At the moment I take the value, turning it into a string and IN part in the WHERE clause holds the string, allowing the WHERE clause to read all the values from it. I would expect the where clause to read everything in the string as 1 complete string of VARCHAR2 data but this would not be the case if this part of the code at least was correct. The code is as follows:
--Global variable section contains:
var_user_chosen_map_list_ids VARCHAR2(32767);
PROCEDURE PROCMAPSEARCH (par_user_chosen_map_list_ids PKG_ARR_MAPS.ARR_MAP_LIST)
IS
CURSOR cur_map_search (par_user_chosen_map_list_ids IN NUMBER)
IS
SELECT MI.map_date
       MT.map_title,
FROM map_info MI,
     map_title MT,
WHERE MI.map_title_id = MT.map_title_id
AND MI.map_publication_id IN
(var_user_chosen_map_list_ids);
var_map_list_to_compare VARCHAR2(32767) := '';
var_exe_imm_map VARCHAR2(32767);
BEGIN
FOR rec_user_chosen_map_list_ids IN 1 .. par_user_chosen_map_list_ids.count
LOOP
   var_user_chosen_map_list_ids := var_user_chosen_map_list_ids ||
   '''' ||
   par_user_chosen_map_list_ids(rec_user_chosen_map_list_ids) ||
END LOOP;
var_user_chosen_map_list_ids := substr(var_user_chosen_map_list_ids,
                                        1,
                                        length(var_user_chosen_map_list_ids)-1);
var_exe_imm_map := 'FOR rec_search_entered_details IN cur_map_search
LOOP
htp.print('Map date: ' || cur_map_search.map_date || ' Map title: ' || cur_map_search.map_title)
END LOOP;';
END PROCMAPSEARCH;EXECUTE IMMEDIATE var_exe_imm_map;
I would be grateful of any comments or advice.
Kind regards
Tim

I would like to thank everyone for their kind help.
I have now successfully converted my code for use with dynamic SQL. Part of my problem was getting the concept confused a little, especially as I could get everything work in a static cursor, including variables, as long as they did not contain multiple values. I have learnt that dynamic sql runs the complete select statement at runtime. However even with this I was getting concepts confused. For example I was including variables and the terminator; inside my select string, where as these should be outside it. For example the following is wrong:
     TABLE (sys.dbms_debug_vc2coll(par_user_chosen_map_list_ids))....
AND MI.map_publication_id = column_value;';Where as the following is correct:
     TABLE (sys.dbms_debug_vc2coll('||par_user_chosen_map_list_ids||'))....
AND MI.map_publication_id = column_value';PL/SQL is inserting the values and then running the select statement, as opposed to running the select statement with the variables and then accessing the values stored in those variables. Once I resolved that it worked. My revised code is as follows:
--Global variable section contains:
var_user_chosen_map_list_ids VARCHAR2(32767);
var_details VARCHAR(32767);
PROCEDURE PROCMAPSEARCH (par_user_chosen_map_list_ids PKG_ARR_MAPS.ARR_MAP_LIST)
IS
BEGIN
FOR rec_user_chosen_map_list_ids IN 1 .. par_user_chosen_map_list_ids.count
LOOP
   var_user_chosen_map_list_ids := var_user_chosen_map_list_ids ||
   '''' ||
   par_user_chosen_map_list_ids(rec_user_chosen_map_list_ids) ||
END LOOP;
var_user_chosen_map_list_ids := substr(var_user_chosen_map_list_ids,
                                        1,
                                        length(var_user_chosen_map_list_ids)-1);
var_details := FUNCMAPDATAFIND (var_user_chosen_map_list_ids);
htp.print(var_details);
END PROCMAPSEARCH;
FUNCTION FUNCMAPDETAILS (par_user_chosen_map_list_ids IN VARCHAR2(32767)
RETURN VARCHAR2
AS
TYPE cur_type_map_search IS REF CURSOR;
cur_map_search cur_type_map_search;
var_map_date NUMBER(4);
var_map_title VARCHAR2(32767);
begin:
OPEN cur_map_search FOR
'SELECT MI.map_date,
       MT.map_title
FROM map_info MI,
     map_title MT,
     TABLE (sys.dbms_debug_vc2coll(' || par_user_chosen_map_list_ids || '))
WHERE MI.map_title_id = MT.map_title_id
AND MI.map_publication_id = column_value';
LOOP
FETCH cur_map_compare INTO
var_map_date,
var_map_title;
var_details := var_details || 'Map date: '||
                    var_map_date ||
                    'Map title: ' ||
                    var_map_title;
EXIT WHEN cur_map_compare%NOTFOUND;
END LOOP;
RETURN var_details;
END FUNCMAPDETAILS;Kind regards
Tim

Similar Messages

  • Dynamic where clause for MULTIPLE values

    In the following of dynamic where clause?
    i have some somewhat different problem.
    Is a dynamic where clause for multiple values possible?
    If the inputvariable varCode1,varCode2,varCode3,varCode4 are 0 then show all id's otherwise filter the resultset on var1 and/or var2,and/or var3,and/or var4.
    Example table:
    create table t
    (d int,var int);
    insert into t values (1 ,1 );
    insert into t values (2 ,1 );
    insert into t values (3 ,2 );
    insert into t values (4 ,3 );
    insert into t values (5 ,4 );
    insert into t values (6 ,4 );
    insert into t values (7 ,4 );
    insert into t values (8 ,4 );
    insert into t values (9 ,5 );
    insert into t values (10, 6);
    insert into t values (11, 6);
    So what i want to change the where clause upon the value of the varCodes. If var1 and var are not 0 a "AND" should be used otherwise an "OR"
    select id
    from tst
    where var = DECODE( :varCode1, 0, var, :varCode1)
    or/and(?) DECODE( :varCode2, 0, var, :varCode2)
    or DECODE( :varCode3, 0, var, :varCode3)
    or DECODE( :varCode4, 0, var, :varCode4)

    Please turn off your Caps Lock
    and try this link
    Dynamic WHERE clause

  • Creating WHERE clause for an outer join using DatabaseFilter

    Hi all,
    I read a post on thie group about constructing the WHERE clause for a RowSet Controls
    SQL Query using the DatabaseFilter and this is what it said:
    ****************************************************************************The
    following example shows adding part of a WHERE clause in an action method of a
    page flow:
    DatabaseFilter.FilterTerm term = new DatabaseFilter.FilterTerm(); term.sColumnName
    = "name"; term.op = DatabaseFilter.opContains; // there are ops for equals, less
    than, etc... term.value = form.getPartialName();
    // You can also add sort terms for an ORDER BY clause allNames = dbControl.getNames(new
    DatabaseFilter(new DatabaseFilter.FilterTerm[] {term}, null));
    I am trying to create a where clause which uses a join like this:
    Select * from x,y where x.id=y.id (+)
    ie. All values from x.id but only corrosponding ones from y.id.
    Is there any way to build this outer join query using the DatabaseFilter class
    or am i forced to use a String which is contruct in my page flow as the where
    clause?like so:
    * @jc:sql command-type="grid"
    * rowset-name="RFPSRowSet"
    * max-rows="1000"
    * statement::
    * SELECT RFPS.RFP_ID,RFPS.NAME AS RFP_NAME,RFPS.FFO_NUMBER,RFPS.RFP_TYPE,RFPS.CFDA_NUMBER,COMPETITIONS.NAME
    AS COMP_NAME,COMPETITIONS.COMPETITION_ID FROM RFPS,COMPETITIONS WHERE {sql: whereClause
    } {sql: filter.getOrderByClause ()}
    public RowSet getAllRfps(java.lang.String whereClause,DatabaseFilter filter)
    throws SQLException;
    and in my pageFlow action, i do the following:
    StringBuffer whereClause= new StringBuffer();
    whereClause.append("RFPS.RFP_ID = COMPETITIONS.RFP_ID (+)");
    if ((form.getRfpTitle() != null) &&
    (!form.getRfpTitle().equalsIgnoreCase("")))
    whereClause.append(" AND UPPER(RFPS.NAME) LIKE %"+form.getRfpTitle().toUpperCase());
    if ((form.getCfdaNumber() != null) &&
    (!form.getCfdaNumber().equalsIgnoreCase("")))
    whereClause.append(" AND RFPS.CFDA_NUMBER ="+form.getCfdaNumber());
    if ((form.getFfoNumber() != null) &&
    (!form.getFfoNumber().equalsIgnoreCase("")))
    whereClause.append(" AND RFPS.FFO_NUMBER ="+form.getFfoNumber());
    sortFilterService = SortFilterService.getInstance(getRequest());
    DatabaseFilter filter=sortFilterService.getDatabaseFilter(getGridName());
    log.debug("***********"+whereClause.toString()+"***********");
    allRows = searchRfaAndComp.getAllRfps(whereClause.toString(),filter);
    Thanks in advance for your help,
    Regards,
    Vik.

    Thanks for your reply. Just one more question....if we indeed are trying to use
    a simple query and have a where clause like "select * from x where upper(x) like
    {x}", how do we set the UPPER filter on the column using the database filter?
    I see a IDENTIFIER.ISUPPER static field on that DatabaseFilter but am unsure how
    to use it. Would appreciate any pointers .
    Thanks again,
    Vik
    Eddie O'Neil <[email protected]> wrote:
    Vik--
    I believe that the approach that you describe below is the best one
    for dealing with outer joins
    with the DatabaseFilter.
    Apologies for the limitation...
    Eddie
    vik wrote:
    Hi all,
    I read a post on thie group about constructing the WHERE clause fora RowSet Controls
    SQL Query using the DatabaseFilter and this is what it said:
    ****************************************************************************The
    following example shows adding part of a WHERE clause in an actionmethod of a
    page flow:
    DatabaseFilter.FilterTerm term = new DatabaseFilter.FilterTerm(); term.sColumnName
    = "name"; term.op = DatabaseFilter.opContains; // there are ops forequals, less
    than, etc... term.value = form.getPartialName();
    // You can also add sort terms for an ORDER BY clause allNames = dbControl.getNames(new
    DatabaseFilter(new DatabaseFilter.FilterTerm[] {term}, null));
    I am trying to create a where clause which uses a join like this:
    Select * from x,y where x.id=y.id (+)
    ie. All values from x.id but only corrosponding ones from y.id.
    Is there any way to build this outer join query using the DatabaseFilterclass
    or am i forced to use a String which is contruct in my page flow asthe where
    clause?like so:
    * @jc:sql command-type="grid"
    * rowset-name="RFPSRowSet"
    * max-rows="1000"
    * statement::
    * SELECT RFPS.RFP_ID,RFPS.NAME AS RFP_NAME,RFPS.FFO_NUMBER,RFPS.RFP_TYPE,RFPS.CFDA_NUMBER,COMPETITIONS.NAME
    AS COMP_NAME,COMPETITIONS.COMPETITION_ID FROM RFPS,COMPETITIONS WHERE{sql: whereClause
    sql: filter.getOrderByClause ()}* ::
    public RowSet getAllRfps(java.lang.String whereClause,DatabaseFilter
    filter)
    throws SQLException;
    and in my pageFlow action, i do the following:
    StringBuffer whereClause= new StringBuffer();
    whereClause.append("RFPS.RFP_ID = COMPETITIONS.RFP_ID (+)");
    if ((form.getRfpTitle() != null) &&
    (!form.getRfpTitle().equalsIgnoreCase("")))
    whereClause.append(" AND UPPER(RFPS.NAME) LIKE %"+form.getRfpTitle().toUpperCase());
    if ((form.getCfdaNumber() != null) &&
    (!form.getCfdaNumber().equalsIgnoreCase("")))
    whereClause.append(" AND RFPS.CFDA_NUMBER ="+form.getCfdaNumber());
    if ((form.getFfoNumber() != null) &&
    (!form.getFfoNumber().equalsIgnoreCase("")))
    whereClause.append(" AND RFPS.FFO_NUMBER ="+form.getFfoNumber());
    sortFilterService = SortFilterService.getInstance(getRequest());
    DatabaseFilter filter=sortFilterService.getDatabaseFilter(getGridName());
    log.debug("***********"+whereClause.toString()+"***********");
    allRows = searchRfaAndComp.getAllRfps(whereClause.toString(),filter);
    Thanks in advance for your help,
    Regards,
    Vik.

  • ADF dynamic where clause for VO query using BC

    I'm hoping someone can help me out. I have a read only view object that I want to filter results based on some user choices. For example the user may want to see all results or they may only want to see a much smaller subset. This is for an error dashboard, the smaller subset maybe by application or maybe by application and by error severity. I think I can use a dynamic where clause but I'm not sure, Can someone get me started down the right path, or post an example that I can see.

    Hi user,
    You can use a dynamic where clause for this, but maybe there is a more practical option. Maybe you can have a fixed where clause, but using a bind parameter, like:
    vo.application like :applicationParam. This makes an executeWithParams method available that you can call from your page, and use in the bindings. This parameter you can populate with the results of for example a poplist, with a default value of '%'.
    When you do want to use a dynamic where clause, you will need to add a method to the java code of your application module, and make this method available for the client. In this method, you can use findViewObject to retrieve your VO, use VO.setWhereClause to set the whereclause to what you want, and then call VO.executeQuery. This method can then again be called from the page.
    Success,
    Jeroen van Veldhuizen

  • DATAMOVER: Error: Syntax error in where clause for PSOPRDEFN

    SET LOG C:\PSUSER_HRM.log;
    SET input F:\psoprdefn.dat;
    IMPORT psoprdefn where OPRId = 'PS';
    when i execute this command after importing .dat file from my database i get error:
    Error: Syntax error in where clause for PSOPRDEFN
    any suggestions pls help....
    Thanks
    aravind
    Edited by: 967641 on Nov 20, 2012 11:39 AM
    Edited by: 967641 on Nov 20, 2012 11:40 AM

    That is correct.
    Datamover tries to insert data in PSOPRDEFN and rows exist with these keys.
    To avoid this you can add the following statement in your script:
    SET UPDATE_DUPS;
    This will update the values other than the keys if a row already exists in the database with the keys in the dat file.
    I can advice you to buy the new book of Jim Marion, PeopleSoft PeopleTools Data Management and Upgrade Handbook
    http://www.amazon.com/PeopleSoft-PeopleTools-Management-Upgrade-Handbook/dp/0071787925/ref=sr_1_1?ie=UTF8&qid=1353575734&sr=8-1&keywords=jim+j+marion
    It has an entire chapter on how to use datamover.
    Hakan

  • Using user defined function in where clause

    Hi,
    I have defined function to get maximum date before passed date on the table 'A' and I'm using the same function to get details on that date from the same table 'A' in where clause.
    for ex:
    SELECT x,y,z
    FROM A
    WHREE a.date = max_date;
    But on one database instance it is running fine and on other it is going in a infinite loop.
    Pls help me out
    Thanks in advance,
    Prashant

    Hello Siva,
    sorry, but I don't understand your reply:
    This is not right forum to posting this question.
    You are from which module or working any 3rd party application.
    MaxDB 7.7.07.16 is the community version of MaxDb,
    we are not using it for SAP
    and no 3rd party software is required to reproduce my problem,
    Sql Studio or Database Studio will do.
    Regards,
    Silke Arnswald

  • Using round off function in where clause

    Hi All,
    I'm trying to use round off function in where clause, I seek help in completing this script.
    WITH CR_Details AS
    (Select
    request_id,
    parent_request_id,
    fcpt.user_concurrent_program_name Request_Name, phase_code, status_code,
    round((fcr.actual_completion_date - fcr.actual_start_date),3) * 24 * 60 as Run_Time,
    round(avg(round(to_number(actual_start_date - fcr.requested_start_date),3) * 1440),2) wait_time,
    fu.User_Name Requestor,
    fcr.argument_text parameters,
    to_char (fcr.requested_start_date, 'MM/DD HH24:mi:SS') requested_start,
    to_char(actual_start_date, 'MM/DD/YY HH24:mi:SS') ACT_START,
    to_char(actual_completion_date, 'MM/DD/YY HH24:mi:SS') ACT_COMP,
    fcr.completion_text
    From
    apps.fnd_concurrent_requests fcr,
    apps.fnd_concurrent_programs fcp,
    apps.fnd_concurrent_programs_tl fcpt,
    apps.fnd_user fu
    Where 1=1
    and fcr.concurrent_program_id = fcp.concurrent_program_id
    and fcp.concurrent_program_id = fcpt.concurrent_program_id
    and fcr.program_application_id = fcp.application_id
    and fcp.application_id = fcpt.application_id
    and fcr.requested_by = fu.user_id
    and fcpt.language = 'US'
    and fcr.actual_start_date like sysdate )
         select crd.*
         from CR_Details crd
         where Run_time <> '0'
         AND wait_time <> '0'
    GROUP BY
    crd.request_id,
    crd.parent_request_id,
    crd.fcpt.user_concurrent_program_name,
    crd.requested_start_date,
    crd.User_Name,
    crd.argument_text,
    crd.actual_completion_date,
    crd.actual_start_date,
    crd.phase_code,
    crd.status_code,
    crd.resubmit_interval,
    crd.completion_text,
    crd.resubmit_interval,
    crd.resubmit_interval_unit_code,
    crd.description
    Not sure about the GROUPBY function referencing the "crd." .

    Hi,
    The best thing for you to do is start over. Start as small as possible, then take baby steps.
    Pick one of the tables; fcr perhaps, and write a query that just uses that table, like this:
    SELECT    *
    FROM       apps.fnd_concurrent_requests     fcr
    WHERE       fcr.actual_start_date          >= TRUNC (SYSDATE)
    AND       fcr.actual_start_dt          <  TRUNC (SYSDATE) + 1
    ;(I think this is what you meant to do when you said "... LIKE SYSDATE".)
    Make sure this little query gets credible results. When that tiny query is working perfectly, add another line or two. You can cut and paste code from what you posted, if that helps you.
    If you get stuck, post the last version of your code that worked perfectly, and the latest version (only a line or two bigger) that has the problem. Describe what the problem is. If you get an error, post the complete error message. In any event, post CREATE TABLE and INSERT statements for all the tables and columns needed to run the query, and the results you want to get from that query.
    When you post any code, format it, so that how the code looks on the screen gives some clues about how it is working.
    When you post any formatted text on this site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
    If you going to use the AVG function in the sub-query, then you probably need to do a GROUP BY in the sub-query.
    If you're not using any aggregate functions (like AVG) in the main query, then you probably don't want to do a GROUP BY in the main query.
    I know this is a lot of work.  I'm sorry.  If there was an easier way, I wouldn't ask you to do all this.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to use a function in a Where Clause?

    Hi,
    I've got a doubt. If MY_FUNCT is a function that returns a boolean, can I use it in a where clause for writing a query like this?:
    select ...
    from table a
    where ...
    and MY_FUNC (a.field) = true
    Thanks!
    Edited by: Mark1970 on 2-lug-2010 3.27

    Bear in mind that this could kill your performance.
    Depending on what you're doing, how many tables and other predicates are involved, you might want to try to eliminate all other data early before applying your function predicate otherwise your function might be called more times than you might have imagined. Strategies for this include subquery factoring and the old ROWNUM trick for materialising an inline view.
    If performance is impacted, you might also want to consider using a function-based index provided that the function is deterministic.

  • A somewhat more complex use of EXECUTE_QUERY with a Where clause...

    Basically, what I need to be able to do is when the form receives a certain parameter upon opening; it must immediately run a certain query and populate the data blocks.
    I do understand the concept of setting the DEFAULT_WHERE in the PRE_QUERY trigger for the block; but I don't think this will work in my situation.
    The reason being is that each data block must run 2 separate queries; and BOTH resulting queries must be populated to each data block, and not overwrite eachother...
    Not only that, but the query being executed requires me to reference 2 separate tables (the data coming from one, however its comparing results from 2 separate tables, so I don't think simply modifying the where clause for the data block will even be possible to achieve the results I am looking for.
    Maybe further explanation of my queries may help the situation. Basically, each data block is linked to a table for the current logged in user, and then there is a production table as well. When ANYTHING is modified, added, or deleted on the current user's table, they are suppose to "publish" the record to the production table. The EXECUTE_QUERY statement will be responsible for running the query that will populate ALL the records that have yet to be published to the production table. So basically, its running a query that will use an ID and compare each individual field by that ID for any changes from the production table. Then, it runs another query to find records that are in either the production table or user table, and not the other; to flag a new record or deleted record.
    I've been thinking about possible ways to do this, but have had no luck unfortunately;
    ANY guidance will be greatly appreciated it. I do understand that my description of the problem may be hard to comprehend, so if you need further clarification please ask.
    Jason
    Message was edited by:
    user558647

    It would be helpful to give an example of the sort of data in each table and what you want to show in each block. I probably didn't understand most of what you wrote but I think the following may be analogous to your situation and requirements (but you'll have more columns of course):
    SQL> CREATE TABLE t_user AS
      2    SELECT
      3      ROWNUM id,
      4      object_name col1,
      5      object_type col2
      6    FROM all_objects
      7    WHERE ROWNUM < 10;
    Table created.
    SQL>
    SQL> DELETE FROM t_user WHERE id = 1;
    1 row deleted.
    SQL>
    SQL> CREATE TABLE t_published AS
      2    SELECT
      3      ROWNUM id,
      4      CASE Mod(ROWNUM,2)
      5        WHEN 0 THEN SubStr(object_name,1,2)
      6        ELSE object_name
      7        END AS col1,
      8      object_type col2
      9    FROM all_objects
    10    WHERE ROWNUM < 9;
    Table created.
    SQL>
    SQL>
    SQL> SELECT * FROM t_user;
            ID COL1                           COL2
             2 I_USER1                        INDEX
             3 CON$                           TABLE
             4 UNDO$                          TABLE
             5 C_COBJ#                        CLUSTER
             6 I_OBJ#                         INDEX
             7 PROXY_ROLE_DATA$               TABLE
             8 I_IND1                         INDEX
             9 I_CDEF2                        INDEX
    8 rows selected.
    SQL> SELECT * FROM t_published;
            ID COL1                           COL2
             1 ICOL$                          TABLE
             2 I_                             INDEX
             3 CON$                           TABLE
             4 UN                             TABLE
             5 C_COBJ#                        CLUSTER
             6 I_                             INDEX
             7 PROXY_ROLE_DATA$               TABLE
             8 I_                             INDEX
    8 rows selected.
    SQL>
    SQL> -- yet to be published to the production table
    SQL> -- includes records previously published and then updated, but not new
    SQL> -- records which have never been published (these are in the other query)
    SQL> SELECT u.id, u.col1, u.col2
      2  FROM t_user u, t_published p
      3  WHERE u.id = p.id
      4  AND (
      5    u.col1 != p.col1
      6    OR u.col2 != p.col2
      7    )
      8  ;
            ID COL1                           COL2
             2 I_USER1                        INDEX
             4 UNDO$                          TABLE
             6 I_OBJ#                         INDEX
             8 I_IND1                         INDEX
    SQL>
    SQL> -- new and deleted records
    SQL> SELECT * FROM(
      2    SELECT id, col1, col2, 'NEW' status FROM t_user
      3    UNION ALL
      4    SELECT id, col1, col2, 'DELETED' status FROM t_published
      5  )
      6  WHERE id NOT IN(
      7    SELECT id FROM t_user
      8    INTERSECT
      9    SELECT id FROM t_published
    10  )
    11  ;
            ID COL1                           COL2                STATUS
             9 I_CDEF2                        INDEX               NEW
             1 ICOL$                          TABLE               DELETED
    SQL> Basically, I think the answer is in the query and not the Where Clause.
    I think you want one of these queries in each block, so set the blocks' queries (are you changing that query based on the parameter passed in, or just executing the query, you're not clear on that) and then do
    go_block('B2');
    execute_query;
    go_block('B1');
    execute_query;

  • Where clause for polling database Adapter

    I am creating a database adapter that polls a table for documents that are more than a month old based on a last updated field. For My where clause in the select statement I would like to have something like:
    where last_updated_date < add_months(sysdate, -1)
    but the where clause wizard will only allow me to use field names or literals. Any suggestions?

    Hi Stephen,
    Have you explored the option of calling a Stored Procedure or function which will do the SQL query as specified by you?
    Regards,
    lakshmi

  • Where clause for TaskLOVVO on OTL Timecard

    Hi,
    Following is the customization on our OTL timecard layout(Projects and Payroll Layout):
    ->Extended TaskLOVVO and based on a value selected in TaskLOV, i am defaulting Hours type.
    The dynamic where clause for the TaskLOVO is taken care of by the below QUALIFIER_ATTRIBUTES(Same as seeded layout)
    QUALIFIER_ATTRIBUTE14 = "HxcCuiTaskProjectId|PROJECT|Y#HxcCuiTaskProjectNumber|PROJECT-DISPLAY|Y"
    QUALIFIER_ATTRIBUTE15 = "project_id = ::HxcCuiTaskProjectId#upper(project_number) = upper(::HxcCuiTaskProjectNumber)"
    But in some scenarios the dynamic layout is not getting appended to TaskLOVO and the query behind the TaskLOV is pulling too many records.
    This issue is happening on Fridays when around 15000 employees submit the timecards, as Friday is our deadline for Timecard submission.
    I have tried different scenarios to replicate this issue in test intances but I am not able to replicate it.
    Please suggest what could be the issue and why is the whereclause is not getting appended in some scenarios.
    Thank you

    Hi,
    Thank you for your reply.
    The whoole LDT file is more than 30000 characters, which is not allowed in the post, so I have included only the lines which have customization.
    FYI: This is a Projects and Payroll layout.
    Following is my LDT file:
    # $Header: hxczzhxclayt0093.ldt 120.0 2008/02/08 09:26:10 bbayragi noship $
    # dbdrv: exec fnd bin FNDLOAD bin &phase=dat+10 checkfile:~PROD:~PATH:~FILE &ui_apps 0 Y UPLOAD @HXC:patch/115/import/hxclaytlayoutsld.lct @~PROD:~PATH/~FILE
    LANGUAGE = "US"
    LDRCONFIG = "hxclaytlayoutsld.lct 120.0"
    #Source Database seed121
    #RELEASE_NAME 12.1.0
    # -- Begin Entity Definitions --
    BEGIN HXC_LAYOUT_COMPONENTS
    "Projects Details Alternate Timecard Layout - Project"
    OWNER = "ORACLE12.1.0"
    COMPONENT_VALUE = "PROJECT"
    REGION_CODE = "HXC_CUI_TIMECARD"
    REGION_CODE_APP_SHORT_NAME = "HXC"
    ATTRIBUTE_CODE = "HXC_TIMECARD_PROJECT"
    ATTRIBUTE_CODE_APP_SHORT_NAME = "HXC"
    SEQUENCE = "200"
    COMPONENT_DEFINITION = "LOV"
    RENDER_TYPE = "WEB"
    PARENT_COMPONENT = "Projects Details Alternate Timecard Layout - Day Scope Building blocks for worker timecard matrix"
    LAST_UPDATE_DATE = "2004/05/24"
    BEGIN HXC_LAYOUT_COMP_QUALIFIERS
    "Projects Details Alternate Timecard Layout - Project"
    OWNER = "ORACLE12.1.0"
    QUALIFIER_ATTRIBUTE_CATEGORY = "LOV"
    QUALIFIER_ATTRIBUTE1 = "ProjectLOVVO"
    QUALIFIER_ATTRIBUTE2 = "N"
    QUALIFIER_ATTRIBUTE3 = "HXC_CUI_PROJECT_DETAILS_LOV"
    QUALIFIER_ATTRIBUTE4 = "809"
    QUALIFIER_ATTRIBUTE5 = "25"
    QUALIFIER_ATTRIBUTE6 = "HxcCuiProjectDetails|PROJECT-DISPLAY|CRITERIA|N|HxcCuiProjectId|PROJECT|RESULT|N|HxcCuiProjectDetails|PROJECT-DISPLAY|RESULT|N|HxcCuiProjectCoOrgId|LOCATION1|RESULT|N|HxcCuiProjectName|CNAME|RESULT|N"
    QUALIFIER_ATTRIBUTE8 = "ProjectDetails"
    QUALIFIER_ATTRIBUTE9 = "ProjectId#NUMBER"
    QUALIFIER_ATTRIBUTE10 = "oracle.apps.hxc.selfservice.timecard.server.ProjectLOVVO"
    QUALIFIER_ATTRIBUTE11 = "RESOURCE_IDENTIFIER_ID"
    QUALIFIER_ATTRIBUTE17 = "OraTableCellText"
    QUALIFIER_ATTRIBUTE20 = "N"
    QUALIFIER_ATTRIBUTE21 = "Y"
    QUALIFIER_ATTRIBUTE22 = "L"
    QUALIFIER_ATTRIBUTE25 = "FLEX"
    QUALIFIER_ATTRIBUTE26 = "PROJECTS"
    QUALIFIER_ATTRIBUTE27 = "Attribute1"
    QUALIFIER_ATTRIBUTE28 = "PROJECT"
    LAST_UPDATE_DATE = "2004/05/24"
    END HXC_LAYOUT_COMP_QUALIFIERS
    END HXC_LAYOUT_COMPONENTS
    BEGIN HXC_LAYOUT_COMPONENTS
    "Projects Details Alternate Timecard Layout - Task"
    OWNER = "ORACLE12.1.0"
    COMPONENT_VALUE = "TASK"
    REGION_CODE = "HXC_CUI_TIMECARD"
    REGION_CODE_APP_SHORT_NAME = "HXC"
    ATTRIBUTE_CODE = "HXC_TIMECARD_TASK"
    ATTRIBUTE_CODE_APP_SHORT_NAME = "HXC"
    SEQUENCE = "210"
    COMPONENT_DEFINITION = "LOV"
    RENDER_TYPE = "WEB"
    PARENT_COMPONENT = "Projects Details Alternate Timecard Layout - Day Scope Building blocks for worker timecard matrix"
    LAST_UPDATE_DATE = "2004/05/24"
    BEGIN HXC_LAYOUT_COMP_PROMPTS "HxcCuiTaskProjectId" "AK_PROMPT"
    OWNER = "ORACLE12.1.0"
    REGION_CODE = "HXC_CUI_TIMECARD"
    REGION_APP_SHORT_NAME = "HXC"
    ATTRIBUTE_CODE = "HXC_TIMECARD_PROJECT"
    ATTRIBUTE_APP_SHORT_NAME = "HXC"
    LAST_UPDATE_DATE = "2004/05/24"
    END HXC_LAYOUT_COMP_PROMPTS
    BEGIN HXC_LAYOUT_COMP_QUALIFIERS
    "Projects Details Alternate Timecard Layout - Task"
    OWNER = "ORACLE12.1.0"
    QUALIFIER_ATTRIBUTE_CATEGORY = "LOV"
    QUALIFIER_ATTRIBUTE1 = "TaskLOVVO"
    QUALIFIER_ATTRIBUTE2 = "N"
    QUALIFIER_ATTRIBUTE3 = "HXC_CUI_TASK_DETAILS_LOV"
    QUALIFIER_ATTRIBUTE4 = "809"
    QUALIFIER_ATTRIBUTE5 = "10"
    QUALIFIER_ATTRIBUTE6 = "HxcCuiTaskDetails|TASK-DISPLAY|CRITERIA|N|HxcCuiTaskProjectId|PROJECT|PASSIVE_CRITERIA|Y|HxcCuiTaskId|TASK|RESULT|N|HxcCuiTaskDetails|TASK-DISPLAY|RESULT|N|HxcCuiTaskBillableFlag|EXPTYPE|RESULT|N"
    QUALIFIER_ATTRIBUTE8 = "TaskDetails"
    QUALIFIER_ATTRIBUTE9 = "TaskId#NUMBER"
    QUALIFIER_ATTRIBUTE10 = "oracle.apps.hxc.selfservice.timecard.server.TaskLOVVO"
    QUALIFIER_ATTRIBUTE11 = "RESOURCE_IDENTIFIER_ID|TIMECARD_BIND_END_DATE"
    QUALIFIER_ATTRIBUTE14 = "HxcCuiTaskProjectId|PROJECT|Y#HxcCuiTaskProjectNumber|PROJECT-DISPLAY|Y"
    QUALIFIER_ATTRIBUTE15 = "project_id = ::HxcCuiTaskProjectId#upper(project_number) = upper(::HxcCuiTaskProjectNumber)"
    QUALIFIER_ATTRIBUTE17 = "OraTableCellText"
    QUALIFIER_ATTRIBUTE20 = "N"
    QUALIFIER_ATTRIBUTE21 = "Y"
    QUALIFIER_ATTRIBUTE22 = "L"
    QUALIFIER_ATTRIBUTE25 = "FLEX"
    QUALIFIER_ATTRIBUTE26 = "PROJECTS"
    QUALIFIER_ATTRIBUTE27 = "Attribute2"
    QUALIFIER_ATTRIBUTE28 = "TASK"
    LAST_UPDATE_DATE = "2004/05/24"
    END HXC_LAYOUT_COMP_QUALIFIERS
    END HXC_LAYOUT_COMPONENTS
    BEGIN HXC_LAYOUT_COMPONENTS
    "Projects Details Alternate Timecard Layout - Location"
    OWNER = "CUSTOM"
    COMPONENT_VALUE = "LOCATION"
    REGION_CODE = "HXC_CUI_TIMECARD"
    REGION_CODE_APP_SHORT_NAME = "HXC"
    ATTRIBUTE_CODE = "HXC_CUI_LOCATION_LABEL"
    ATTRIBUTE_CODE_APP_SHORT_NAME = "HXC"
    SEQUENCE = "215"
    COMPONENT_DEFINITION = "CHOICE_LIST"
    RENDER_TYPE = "WEB"
    PARENT_COMPONENT = "Projects Details Alternate Timecard Layout - Day Scope Building blocks for worker timecard matrix"
    LAST_UPDATE_DATE = "2004/05/24"
    BEGIN HXC_LAYOUT_COMP_QUALIFIERS "Projects Details Alternate Timecard Layout - Location"
    OWNER = "CUSTOM"
    QUALIFIER_ATTRIBUTE_CATEGORY = "CHOICE_LIST"
    QUALIFIER_ATTRIBUTE1 = "Custom2VO"
    QUALIFIER_ATTRIBUTE4 = "N"
    # QUALIFIER_ATTRIBUTE5 = "10"
    # QUALIFIER_ATTRIBUTE8 = "DisplayValue"
    # QUALIFIER_ATTRIBUTE9 = "Value#NUMBER"
    QUALIFIER_ATTRIBUTE10 = "oracle.apps.hxc.selfservice.timecard.server.Custom2VO"
    QUALIFIER_ATTRIBUTE17 = "OraTableCellText"
    QUALIFIER_ATTRIBUTE20 = "N"
    QUALIFIER_ATTRIBUTE21 = "Y"
    QUALIFIER_ATTRIBUTE22 = "L"
    QUALIFIER_ATTRIBUTE25 = "FLEX"
    QUALIFIER_ATTRIBUTE26 = "Dummy Element Context"
    QUALIFIER_ATTRIBUTE27 = "Attribute15"
    QUALIFIER_ATTRIBUTE28 = "LOCATION1"
    LAST_UPDATE_DATE = "2004/05/24"
    END HXC_LAYOUT_COMP_QUALIFIERS
    END HXC_LAYOUT_COMPONENTS
    BEGIN HXC_LAYOUT_COMPONENTS "Projects Details Alternate Timecard Layout - Expenditure Type"
    OWNER = "ORACLE"
    COMPONENT_VALUE = "EXPENDITURETYPE"
    REGION_CODE = "HXC_CUI_TIMECARD"
    REGION_CODE_APP_SHORT_NAME = "HXC"
    ATTRIBUTE_CODE = "HXC_TIMECARD_EXPTYPE"
    ATTRIBUTE_CODE_APP_SHORT_NAME = "HXC"
    SEQUENCE = "225"
    COMPONENT_DEFINITION = "PACKAGE_CHOICE_LIST"
    RENDER_TYPE = "WEB"
    PARENT_COMPONENT = "Projects Details Alternate Timecard Layout - Day Scope Building blocks for worker timecard matrix"
    LAST_UPDATE_DATE = "2004/05/23"
    BEGIN HXC_LAYOUT_COMP_QUALIFIERS "Projects Details Alternate Timecard Layout - Expenditure Type"
    OWNER = "ORACLE"
    QUALIFIER_ATTRIBUTE_CATEGORY = "PACKAGE_CHOICE_LIST"
    QUALIFIER_ATTRIBUTE1 = "BOLINF.XXHXC_TYPE_CHOICE.EXPTTYPE"
    QUALIFIER_ATTRIBUTE2 = "@RESOURCE_IDENTIFIER_ID|@TIMECARD_BIND_END_DATE"
    QUALIFIER_ATTRIBUTE4 = "N"
    QUALIFIER_ATTRIBUTE8 = "aliasname"
    QUALIFIER_ATTRIBUTE9 = "value#NUMBER"
    QUALIFIER_ATTRIBUTE20 = "N"
    QUALIFIER_ATTRIBUTE21 = "Y"
    QUALIFIER_ATTRIBUTE22 = "R"
    QUALIFIER_ATTRIBUTE24 = "ET_EXPENDITURE_TYPE"
    QUALIFIER_ATTRIBUTE25 = "FLEX"
    QUALIFIER_ATTRIBUTE26 = "OTL_ALIAS_1"
    QUALIFIER_ATTRIBUTE27 = "Attribute1"
    QUALIFIER_ATTRIBUTE28 = "EXPTYPE"
    LAST_UPDATE_DATE = "2004/05/24"
    END HXC_LAYOUT_COMP_QUALIFIERS
    END HXC_LAYOUT_COMPONENTS
    BEGIN HXC_LAYOUT_COMPONENTS "Projects Details Alternate Timecard Layout - Customer name"
    OWNER = "ORACLE"
    REGION_CODE = "HXC_CUI_TIMECARD"
    REGION_CODE_APP_SHORT_NAME = "HXC"
    ATTRIBUTE_CODE = "XXTW_HXC_TIMECARD_CUST_NAME"
    ATTRIBUTE_CODE_APP_SHORT_NAME = "HXC"
    SEQUENCE = "205"
    COMPONENT_DEFINITION = "TEXT_FIELD"
    RENDER_TYPE = "WEB"
    PARENT_COMPONENT = "Projects Details Alternate Timecard Layout - Day Scope Building blocks for worker timecard matrix"
    LAST_UPDATE_DATE = "2004/05/24"
    BEGIN HXC_LAYOUT_COMP_QUALIFIERS "Projects Details Alternate Timecard Layout - Customer name"
    OWNER = "ORACLE"
    QUALIFIER_ATTRIBUTE_CATEGORY = "TEXT_FIELD"
    QUALIFIER_ATTRIBUTE1 = "N"
    QUALIFIER_ATTRIBUTE2 = "Y"
    QUALIFIER_ATTRIBUTE3 = "20"
    QUALIFIER_ATTRIBUTE4 = "1"
    QUALIFIER_ATTRIBUTE5 = "20"
    QUALIFIER_ATTRIBUTE7 = "OraTableCellText"
    QUALIFIER_ATTRIBUTE17 = "NONE"
    QUALIFIER_ATTRIBUTE20 = "Y"
    QUALIFIER_ATTRIBUTE21 = "Y"
    QUALIFIER_ATTRIBUTE22 = "L"
    QUALIFIER_ATTRIBUTE25 = "FLEX"
    QUALIFIER_ATTRIBUTE26 = "PROJECTS"
    QUALIFIER_ATTRIBUTE27 = "Attribute9"
    QUALIFIER_ATTRIBUTE28 = "CNAME"
    QUALIFIER_ATTRIBUTE30 = "Y"
    LAST_UPDATE_DATE = "2004/05/24"
    END HXC_LAYOUT_COMP_QUALIFIERS
    END HXC_LAYOUT_COMPONENTS
    And the query in TASKLOVVO:
    SELECT task.task_number tasknumber, task.task_name, task_details taskdetails, task.task_id taskid, bolinf.GETALIASID(proj.project_type,proj.project_id,task.task_id, :1, :2) billable_flag, task.project_id, task.start_date, task.completion_date, task.chargeable_flag, proj.project_number , proj.project_details from pa_online_tasks_v task ,pa_online_projects_v proj where proj.project_id = task.project_id
    In the above query GETALIASID is a custom function that returns a value.
    Thank you
    Edited by: Santo on Mar 18, 2013 2:12 PM

  • Query Tuning - using CASE statement in the WHERE clause - Duplicate Post

    Duplicate Post by mistake.
    Please check
    Query Tuning - using CASE statement in the WHERE clause
    Edited by: Chaitanya on Jun 9, 2011 2:45 AM
    Edited by: Chaitanya on Jun 9, 2011 2:46 AM

    Duplicate Post by mistake.
    Please check
    Query Tuning - using CASE statement in the WHERE clause
    Edited by: Chaitanya on Jun 9, 2011 2:45 AM
    Edited by: Chaitanya on Jun 9, 2011 2:46 AM

  • Can I use multiple values for a rollup key on the same Endeca record?

    We have a business need to to aggregate our records using different criteria, based on user navigation. We are thinking of using a rollup key with multiple values to help with the aggregation, but we are running into some issues.
    Here is a made-up xample of what we want to do: assume we have a group of products and these products can be organized into groups using parent-child relationships. We would like to create an aggregate record for each parent, and we want the aggregate record for each parent to include all the children for the parent. To achieve this, we use a field called "parent_rec_spec" that holds the parent record spec and we set the same value on the field for the parent and its children. When we do rollup using the parent_rec_spec as the rollup key, we are able to see one aggregate record for each parent (with its children).
    The previous setup worked perfectly for us so far. But now we are getting a business requirement that allows children nodes to be linked to multiple parents at the same time. We were hoping of using another dimension to limit the records based on user roles/characteristics , so that only applicable parents/children are displayed (for example, we can use "market" as an additional filtering property, and we decide to show all parents/children for "North America", while hiding the parents/children for other markets).
    This caused an odd behavior when children are linked to multiple parents. For example, assume that SKUs A and B were linked to parents in "North America" and "Europe" at the same time, and assume that the user chose the "North America" market. The navigation state would eliminate the parents/children that are no in North America, and will also cause the parents/children that are labeled for North America to show up and be aggregated correctly. This however will lead to the creation of additional aggregate records for the A and B using the parent_rec_spec values that would have linked them to the Europe parents (even though the parents are hidden away).
    Here is an example index file that we used to load the test data:
    Update||1
    Market||North America
    Record Type||Product
    Name||Parent 1
    rec_spec||P1
    parent_rec_spec||P1
    EOR
    Update||1
    Market||Europe
    Record Type||Product
    Name||Parent 2
    rec_spec||P2
    parent_rec_spec||P2
    EOR
    Update||1
    Market||North America
    Record Type||Product
    Name||Child A
    rec_spec||A
    parent_rec_spec||P1
    EOR
    Update||1
    Market||North America
    Market||Europe
    Record Type||Product
    Name||Child B
    rec_spec||B
    parent_rec_spec||P1
    parent_rec_spec||P2
    EOR
    Update||1
    Market||North America
    Market||Europe
    Record Type||Product
    Name||Child C
    rec_spec||C
    parent_rec_spec||P1
    parent_rec_spec||P2
    EOR
    Update||1
    Market||Europe
    Record Type||Product
    Name||Child D
    rec_spec||D
    parent_rec_spec||P2
    EOR
    In this setup, we have parent P1 marked for North America with children A, B and C, and parent P2 marked for Europe with B, C and D as children. When we use North America as a filter in the navigation state, and parent_rec_spec as the rollup key, then we will see an aggregate record for P1, A, B and C. But we will also see an aggregate record for B and C by itself (presumably because of the other parent_rec_spec value on these records).
    The actual data that we are testing with is more complicated, but the end result is similar. We also noticed that the additional aggregate records would not be created always, depending on the ordering of the records.
    The question that I need help with is this: is there a way to fine tune the rollup logic so that it can only include certain records (in the example above, we can change the rec_spec from PA and PB to PA_North_America and PB_Europe and then we would be interested in rolling up using values that end with NorthAmerica).
    By the way, we considered using separate rollup keys for each context (like parent_rec_spec_north_america and parent_rec_spec_europe), but the number of contexts is dynamic, and might grow large. So it is not easy for us to create the additional properties on the fly, and we are concerned about the possible large number of dimensions.

    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?catid=2&threadid=1157850

  • Generate WHERE clause for VO using imported entities

    Hi,
    I am using JDev 9.0.3 Preview.
    I attempt to create in one BC project a view based on a join of three entities.
    One of the entities is from the same project, but the other two are imported. After importing the project(s) containing the two additional entities, I have to create the associations (based on database constraints) between the "inner" entity and the "imported" entities. This is OK (apart from known problems, with known workarounds...)
    Now I want to modify the default view created by the wizard for the inner entity and add the two imported entities. When I add the first imported entity, all is OK, the WHERE clause is properly updated, according to the definition of the association. But, when the second imported entity is added, the WHERE clause remains unchanged.
    Is this the expected behaviour?
    Thanks,
    Adrian

    I tried to reproduce this in our production 9.0.3.1035 build which will be available here very shortly on OTN, and this issue is no longer a problem in 9.0.3 production. The WHERE clause is formulated correctly.

  • 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

Maybe you are looking for