Pre-Query

What are the steps for setting up a Pre-Query?
Thanks,
TMS

Hi TMS,
A pre query is just created as you would create any other query. But it becomes a pre-query when you supply the name of this query in a characteristic replacement path variable. The entire scenario could be like, you need to get a list of materials from query 1 (which will become your pre-query) and supply this to query 2 (your ResultSet query). So in Query 2, you need to create a variable for Material that is processed by replacement path and then give query 1 as the name of the query from where to get the material list. So the user will run query 2, but in the background query 1 will run and supply the list to query 2.
Hope this helps...

Similar Messages

  • What is a pre query and in what circumstances it is used?

    Please explain what is a pre query in BW mean,and when is it used...thank you for your answers...

    Hi,
    There is also a possibility to feed a variable with replacement path with a query result and use this variable for restriction in another query:
    http://help.sap.com/saphelp_nw04s/helpdata/en/cf/579b3c494d8e15e10000000a114084/frameset.htm
    Best regards,
    Eugene

  • Building Query in Pre-Query. How to make it more Memory Efficient

    Hello all,
    I have a form with 2 Data Blocks.
    First Block is used for giving query Parameters and second one returns the results based on a View.
    I build the Select Clause in the pre-query based on the Parameters. So every time I have a Different Query.
    Could that create problem in the Database Server due to parsing queries again and again?
    Would using a Different approach (i.e. ref Cursors) be more memory Efficient?
    Thanks

    The pre-query is quite Large so I am pasting only a part of the Code (the rest of it Is Identical).
    In the selects v is the alias of the View of the Second Data Block.
    The :qf_ bind variables are fields of the First block where I give the Parameters.
                   IF :QF_IS_DISPLAYED=1 THEN
                   L_WHERE := L_WHERE || ' AND V.IS_DISPLAYED =''1''';
                   END IF;
                   IF :qf_colour IS NOT NULL THEN
                   L_WHERE := L_WHERE || ' AND item_colour=''' ||:qf_colour ||'''';
                   END IF;
         IF :qf_product_item_colour IS NOT NULL THEN
                   L_WHERE := L_WHERE || ' AND product_item_colour=''' ||:qf_product_item_colour ||'''';
         END IF;
         IF :qf_product_length IS NOT NULL THEN
                   L_WHERE := L_WHERE || ' AND product_length=''' ||:qf_product_length ||'''';
         END IF;
                   IF :qf_apf_batch_id IS NOT NULL THEN
                   L_WHERE := L_WHERE || ' AND apf_batch_id=' ||:qf_apf_batch_id;
                   END IF;
                        if :qf_prod_resource is not null then
                        L_WHERE := L_WHERE ||' AND v.resources = ''' ||:qf_prod_resource ||'''';
                        end if;
                        if :qf_customer_number is not null then
                        L_WHERE := L_WHERE || ' AND FACTORY_ORDER_ID IN (SELECT FA.FACTORY_ORDER_ID
                                                                                                                                                     FROM OE_ORDER_HEADERS_ALL OH,
                                                                                                                                                                    RA_CUSTOMERS RA,
                                                                                                                                                                    XXSC_DEMAND_LINES DL,
                                                                                                                                                                    XXSC_FACTORY_ORDERS FA
                                                                                                                                                     WHERE      OH.SOLD_TO_ORG_ID = RA.CUSTOMER_ID
                                                                                                                                                     AND      DL.SOURCE_HEADER_ID = OH.HEADER_ID
                                                                                                                                                     AND          DL.FACTORY_ORDER_ID = FA.FACTORY_ORDER_ID
                                                                                                                                                     AND               RA.CUSTOMER_NUMBER = ''' ||:qf_customer_number ||''')';
                        end if;

  • Pre-Query - Modifying the default_where

    Hi,
    I'm trying to get the value of the default_where clause to modify it (with set_block_property) after the user has entered the ENTER QUERY MODE and decides to RUN QUERY. I'm creating a Pre-Query event for the module component where the search criteria are entered, but it doesn't seem to work; the where_clause (l_old_where) I retrieve is always empty. My code to retrieve the default_where is:
    BEGIN
    DECLARE
    l_block VARCHAR2(32) := name_in('system.trigger_block');
    l_old_where VARCHAR2(2000);
    BEGIN
    l_old_where := get_block_property(l_block, default_where);
    message('l_old_where =' || l_old_where); --unfortunately this message always returns an empty value
    EXCEPTION
    WHEN VALUE_ERROR THEN
    qms$forms_errors.push(QMS$FORMS_ERRORS.MSGGETTEXT(33, 'Query criteria too complex - simplify and re-query'), 'E', 'OFG', 33);
    qms$forms_errors.raise_failure;
    END;
    END;
    Does anybody know what I am doing wrong? Do you have a better way to retrieve the default_where value?
    Thanks,
    Denis.

    Denis,
    The DEFAULT_WHERE is part of all queries. It is set either in the property palette at design time, or programatically at runtime. If a user does an enter query and specifies some criteria, that criteria is appended to the DEFAULT_WHERE. Thus, interrogating the DEFAULT_WHERE won't help you in this case.
    There is no "nice" way to do this. You have about three triggers you can choose from, that get fired after the users has entered their criteria, but before the query is executed. One is PRE-QUERY, and I forget the other two. One of them is SET-QUERY or something like that.
    What you do is interrogate the fields themselves. For example, if you have two fields: NAME and SALARY, and the user entered the criteria "A%" and ">5000", then it's up to you to examine those fields to see what the user typed. Then you can do with them what you will.
    So you don't get the SQL that Forms generates, but you do get the same info that Forms uses to generate the SQL.
    There is also a gotcha to look out for. When referring to fields in a block that are active during enter-query mode, use the NAME_IN builtin. For example, the SALARY field is of type number, but the criteria is ">5000". That ">" is not acceptable (normally) to a NUMBER field, so you will get errors if you do something like "message('Salary criteria: '||:block.salary);"
    I hope this helps.
    Regards,
    Robin Zimmermann
    Forms Product Management

  • Urgent please _ pre query

    Dear Experts,
    I have a query based on a Multiprovider with 2 cubes (inventory cube and sales order cube). I need extra information of material like material size, season and colour. So I have been advised to include an Ods/DSO in order to get this information as it is not available in the above cubes an to write a pre query for size, season, colour . I never done this before.
    Could you please guide me, urgent please? Do I need to add ods as I added the cubes before to Multiprovider and identify chars and keyfigures and then activate?
    How should I write pre query? How can I link the query I have with the pre query? Please help me
    Thanks,
    Riya

    Actually the fastest and most efficient way of doing will be adding the requested fields in the cube and load the data from DSO to cube, if the DSO is feeding data to the cube. If you don't want to go that route, then you need to include the DSO in your multiprovider and identify the fields you need, since all the cube fields are already in the DSO, then there is no need to keep the cube in the multiprovider. Now you will have one dso and one cube in the multiprovider and in identification you specify all the fields as it is in the cube you had removed.
    Hope I am clear.
    thanks.
    Wond

  • Pre-query trigger issue

    Hi,
    I have a datablock in the form that is based on a DB table. There are few queriable fields in the block including begin and end dates. If i dont use any pre-query trigger, the records are queried fine. But I want to do a range selection between begin and end_Date fields. Therefore I created a pre-query trigger and set a new_where_clause with all my query_fields and set that as defualt where for my DB block.
    SET_BLOCK_PROPERTY (block_id,default_where, where_clause);
    But when I see the query in toad session , the query looks like
    WHERE (field_1 = :1) and field_1 = :1
    that means its running the defualt where clause on the block and the new_where clause at the same time.
    I checked the form and I dont have any calls to execute query....
    what can be the problem?

    1. What is your new_where_clause? (example, please)It's hard to read. Use the \{code\} tag.
    FUNCTION get_comparison_phrase (database_column_name       VARCHAR2,
                                                             relational_operator       VARCHAR2,
                                                             selection_field_name       VARCHAR2)
              RETURN VARCHAR2 IS
         BEGIN
              RETURN CASE
                              WHEN NAME_IN (selection_field_name) IS NOT NULL THEN
                                        ' AND '
                                   || database_column_name
                                   || relational_operator
                                   || ' :'
                                   || selection_field_name
                              ELSE
                                   NULL
                         END;
         END get_comparison_phrase;
    where_clause := 'WHERE (1=1)';
    if NAME_IN (selection_field_name) IS NOT NULL THEN       ' AND '
                                   || database_column_name
                                   || relational_operator
                                   || ' :'
                                   || selection_field_name
                              ELSE
                                   NULL
                         END;
    where_clause :=
         where_clause
              || get_comparison_phrase (
                        'screening_group_num',
                        '=',
                        'EXCEPTIONAL_EVENTS.screening_group_num'
    WHERE (field_1 = :1) and field_1 = :1I do not see 'WHERE (1=1)'; there.
    Edited by: Michael Roy on Oct 21, 2009 9:47 AM

  • Pre query , post query where date = mon-yyyy

    I have a tabular block B2 with many records
    this block items are vouhcerno, voucherdate. voucherno number(6) and voucherdate date.
    when new form instance i execute query it shows me all the records working fine.
    I add one list item here when new form instance this list item got record like
    Jan-2009
    Feb-2009
    Mar-2009
    so on...
    I want that when i select Jan-2009 from list item and press button
    block B2 only show my January 2009 records.
    I tried to this in pre query and also post query trigger but not successful.
    Kindly guide me .

    Arun really tnx, you are helping me.
    I m sorry Your this code also not working.
    i want to add one more condition in this code
    SET_BLOCK_PROPERTY('b2',DEFAULT_WHERE, 'to_char(voucherdate,''fmmon-fmYyyy'')= ''' || Lower(:vdate ) || ''''  );
    And :vtype = "PV'
    {code}
    I m using this
    {code}
    SET_BLOCK_PROPERTY('b2',DEFAULT_WHERE, 'to_char(voucherdate,''fmmon-fmYyyy'')= ''' || Lower(:vdate ) || 'and :B2.vtype = PV'|| ''''  );
    {code}
    but Not return query.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • PRE-QUERY not firing

    I have a Form that has 4 cascading List Item after you make a chose on the Bpost_Tag (4th) you press the Button Execute Query. On the Data Block I have PRE-QUERY as shown below! What I’m trying to get in return is if you chose Bpost_Tag 100 you will get all Bpost_Tags 100 and greater on the Form. Right now all I’m getting in return is one Bpost_Tag of 100.
    Data Block
    PRE-QUERY
    DECLARE
                   wh_clause VARCHAR2(200);
    BEGIN
                   IF :PMISCURR.SYSTEM is not null then
                   wh_clause := 'SYSTEM = '||:PMISCURR.SYSTEM;
              END IF;
                   IF :PMISCURR.COUNTY is not null then
                   wh_clause := wh_clause ||' AND COUNTY = '||:PMISCURR.COUNTY;
              END IF;
                   IF :PMISCURR.ROUTE is not null then
                   wh_clause := wh_clause ||' AND ROUTE = '||:PMISCURR.ROUTE;
              END IF;
                   IF :PMISCURR.BPOST_TAG is not null then
                   wh_clause := wh_clause ||' AND BPOST_TAG >= '||''''||:PMISCURR.BPOST_TAG ||'''';
              END IF;
              Set_Block_Property ('PMISCURR', DEFAULT_WHERE, wh_clause);
    END;
    The Go_Block ('PMISCURR'); is on the Execute Query Button.
    Edited by: Monty on May 13, 2011 12:06 PM

    Andreas
    Based on the same Table!*
    DATA BLOCKS:
    PMISCURR
    ..........SYSTEM
    ..........ROUTE
    ..........COUNTY
    ..........BPOST_TAG
    PMISCURR1
    ..........SYSTEM_1
    ..........ROUTE_1
    ..........COUNTY_1
    ..........BPOST_TAG_1
    I moved the PRE-QUERY as is to PMISCURR1 still got all the values from the Database Table/PMISCURR_BPOST_TAG. I changed the SQL to point to PMISCURR1 and got the same results. I’m just having hard understanding what is wrong. I have asked several coworkers to take a look at it and all they say is it should work my guess is they don’t know either!
    Changed POST-QUERY on PMISCURR!
    DECLARE
    wh_clause VARCHAR2(200);
    BEGIN
    IF :PMISCURR1.SYSTEM_1 is not null then
         wh_clause := 'SYSTEM_1 = '||:PMISCURR1.SYSTEM_1;
    END IF;
    IF :PMISCURR1.COUNTY_1 is not null then
         wh_clause := wh_clause ||' AND COUNTY_1 = '||:PMISCURR1.COUNTY_1;
    END IF;
    IF :PMISCURR1.ROUTE_1 is not null then
         wh_clause := wh_clause ||' AND ROUTE_1 = '||:PMISCURR1.ROUTE_1;
    END IF;
    IF :PMISCURR1.BPOST_TAG_1 is not null then
         wh_clause := wh_clause ||' AND BPOST_TAG_1 >= '||''''||:PMISCURR1.BPOST_TAG_1 ||'''';
    END IF;
    Set_Block_Property ('PMISCURR1', DEFAULT_WHERE, wh_clause);
    END;
    Monty

  • Pre-Query Trigger

    In one of our form ( we generated this from Oracle Designer), we put the Pre-Query trigger to the first block of the form, where we override the default_where so that it includes something liek this
    INSTR (cpb_order_title, 'housing', 1, 1) > 0   AND INSTR (cpb_order_title, 'review', 1, 1 )> 0
    But when during execution, we found that alongwith the above filter, it also appends the regular default_where to the above condition. Something like this
    INSTR (cpb_order_title, 'housing', 1, 1) > 0 AND INSTR (cpb_order_title, 'review', 1, 1 )> 0
    AND (    UPPER (cpb.cpb_order_title) LIKE :1
    AND (cpb.cpb_order_title LIKE :2 OR cpb.cpb_order_title LIKE :3)
    Could not find how it is adding the default condition. Any help would be very much appreciated.
    Thanks
    Deb

    Debra,
    So, this is the default WHERE clause on the block?
    AND ( UPPER (cpb.cpb_order_title) LIKE :1AND (cpb.cpb_order_title LIKE :2 OR cpb.cpb_order_title LIKE :3)>
    I don't see anything in your code that would cause the new where clause to be appended to the original where clause, unless you have code somewhere else that automatically sets the default where clause programatically.
    The fact that your code sample sets the block where clause to an empty string ( '' ) if the order_title is NULL makes me wonder why you have a DEFAULT_WHERE defined in the first place. Not to mention the fact that the first thing your Pre-Query trigger does is set the DEFAULT_WHERE to an empty string as well. My first suggestion is to simply eliminate the WHERE property default value.
    What is the output of your call to "MESSAGE_POPUP?" Is the original WHERE clause listed in the resulting Alert? Have you displayed the contents of the vQuery variable before the DEFAULT_WHERE assignment and if so what it the output?
    Craig...

  • Pre-Query + Webtemplate + Sender/Receiver assignment

    Hi,
    I have a problem with the Variables screen of my query. The situation is as follows:
    - I have Query (let's call it Q1) with a "Replacement Path" variable (V1).
    - The pre-query associated to V1 has 3 variables (va1, va2, va3)
    - I also have a Web template (W1) that is used to display query Q1.
    - In W1, the checkbox for attribute "Force Variables Screen Display" is not checked. That is, I want that the variables screen doesn't come up by default. According to the attribute description, if the checkbox is not checked, "...Display only appears if Mandatory variables are not Filled...", and I don't have any mandatory variables.
    - I use a Sender/Receiver assignment (Tr. RSBBS) to jump from another query (Q2) into W1, assigning values for the 3 variables va1, va2, and va3.
    - As a result of the "jump" from Q2 to W1, I get the Variables Screen of Q1 displayed (with the right values for variables va1, va2 and va3), and only after clicking on "Execute" I get to see the data...
    Now, what I need is to display the data first, and not the variables screen... Any Ideas?
    I hope the description of the scenario is clear... If not, please let me know...
    Kind regards,
    Damian.

    I am facing exactly the same problem except that instead of a RRI, I am using parameterized web template URLs. <b>Damian</b>, If you have solved this problem, can you post how? If not, can someone who sees the problem help ?
    To restate the problem,I have a web template with a query which has a variable which is populated by a replacement path query which has another variable whose value the user enters. I build up the parameterized URL.
    http://dw1-sap.app.*******.com:1041/sap/bw/BEx?SAP-LANGUAGE=E&PAGENO=1&CMD=LDOC&TEMPLATE_ID=<b>PRDPROF</b>&VARIABLE_SCREEN=&VAR_NAME_1=<b>PRDTXT</b>&VAR_OPERATOR_1=CP&VAR_SIGN_1=I&VAR_VALUE_LOW_EXT_1=FEM
    The template PRDPROF is based on a query and has a variable PRDID which is a replacement path which is filled by a query whose variable is PRDTXT and is filled in the above URL. PRDTXT is a selection option variable whose entry is optional and is checked ready for input. 'Change during query navigation' is unchecked.
    For some reason, the variable values are passed onto the parameterized URL and will fill the variable screen but the screen waits for the user to push the execute button.
    Can anybody see what the problem is ? Any input is apperciated.
    Thanks.
    > Hi,
    > I have a problem with the Variables screen of my
    > query. The situation is as follows:
    >
    > - I have Query (let's call it Q1) with a "Replacement
    > Path" variable (V1).
    >
    > - The pre-query associated to V1 has 3 variables
    > (va1, va2, va3)
    >
    > - I also have a Web template (W1) that is used to
    > display query Q1.
    >
    > - In W1, the checkbox for attribute "Force Variables
    > Screen Display" is not checked. That is, I want that
    > the variables screen doesn't come up by default.
    > According to the attribute description, if the
    > checkbox is not checked, "...Display only appears if
    > Mandatory variables are not Filled...", and I don't
    > have any mandatory variables.
    >
    > - I use a Sender/Receiver assignment (Tr. RSBBS) to
    > jump from another query (Q2) into W1, assigning
    > values for the 3 variables va1, va2, and va3.
    >
    > - As a result of the "jump" from Q2 to W1, I get the
    > Variables Screen of Q1 displayed (with the right
    > values for variables va1, va2 and va3), and only
    > after clicking on "Execute" I get to see the data...
    >
    > Now, what I need is to display the data first, and
    > not the variables screen... Any Ideas?
    >
    > I hope the description of the scenario is clear... If
    > not, please let me know...
    >
    > Kind regards,
    >
    >
    > Damian.

  • Pre-query trigger firing twice

    I have a pre-query trigger on a block in a form to set the "default where" as
    SET_BLOCK_PROPERTY (BLOCK_ID, default_where,where_clause);
    but when I look at the current query for the session the where clause looks like
    WHERE screening_group_num = :1 AND (screening_group_num = :2)
    Why is this firing twice?
    I checked this thread : Re: pre-query firing twice but I dont have any calls to execute_query in the form.

    I am setting the where_clause in the pre_query trigger for that block.
    and the copy value is not set for the screening_group_num item or for that matter any other item in the block. For all other items, it dosent really matter if the comparison is done twice (as the values will be same) , but when I have text (string) items, then its a problem. For example:
    Where
    (event_description LIKE '%test%') --- this is from the pre_query trigger where I am doing a string_comparison using 'Like and %%'
    AND (event_description = :1) --i suppose this is from the default where clause of the block                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • What is a Pre-query?

    What is a Pre-query?
    Regards,

    Check if these links help:
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/95/b27f425b595551e10000000a1550b0/frameset.htm
    http://help.sap.com/saphelp_nw04s/helpdata/en/cf/579b3c494d8e15e10000000a114084/frameset.htm
    Pre-Query

  • Join with another table in pre-query

    Hi,
    We have a large data block and we need to order some columns based on street name for example, not id. The base table of db block contains an id_street column, and 'streets' table contains id and name.
    Ok, in pre-query trigger of that block, we have a complex logic and we dynamically build the where clause. At the end, we set the order_By clause of the block, to order the rows, for example we need to order by the 'my_date' column asc (it's a date type column), and street desc; but street NAME, not id. We don't want to use a from clause query, because the dynamically where clause logic it's complex.
    How can we join the db block table with 'streets' table in pre-query, so when constructing the order by clause to specify something like
    set_block_property('ADRESE_NEZONATE', order_by, 'my_date, name desc');where 'name' is the name of the street, from the 'streets' table.
    Is it possible in pre-query, somehow? Or, in my case where can I join with that table and use that column in pre-query at setting order by?
    Thanks!
    Edited by: Roger25 on 26.04.2013 12:31

    I understand what you say but partially.. please explain in more detail how to do that;
    How should look the adrese_nezonate block, then? I have to add a 'name' column and set copy value from item property to 'STREETS.NAME', and database_property No?
    Then the post-query trigger how should look like (the order by clause)? The post-query sends the entire query (with where/order by clauses) to the server, but in that "select... where... order by" (built dynamically) there are only columns from that block (adrese_nezonate). I need to join with streets, INSIDE that query.
    Thanks.

  • How to invoke Standard BOM form in pre-queried mode?

    Hi,
    I need to invoke the Standard Oracle BOM form from a custom form developed.
    I have the Bill Sequence ID, Inventory Item ID and the Organization ID available in the custom form.
    Currently this is how I am trying:
    fnd_function.EXECUTE
         (function_name => 'BOM_BOMFDBOM',
         open_flag => 'Y',
         session_flag => 'N',
         other_params => 'BILL_SEQ_ID="'
         || l_num_bill_seq_id
         || '" INV_ITEM_ID="'
         || l_num_inv_item_id
         || '" ITEM_ID="'
         || l_num_inv_item_id
         || '" ORG_ID="'
         || :parameter.org_id
    || '" G_QUERY_FIND= "'
    || 'TRUE'
         || '"'
    The form does open up. But not pre-queried for the Bill Sequence I pass to it.
    Can anyone please let me know if I am missing something.
    Thanks a bunch,
    Vinay.

    This might help
        If :b_bill_of_matls.Assembly_Item_Id is not null then
          X_Parameters :=
            ' ASSEMBLY_ITEM_ID='||to_char(:b_bill_of_matls.Assembly_Item_id);
          If :b_bill_of_matls.Alternate_bom_Designator is not null then
            X_Parameters := X_Parameters ||
            ' ALTERNATE='||:b_bill_of_matls.Alternate_bom_Designator;
          End if; -- alternate
          X_Parameters := X_Parameters ||
            ' ORG_ID='||to_char(:Parameter.Org_Id)||
            ' ORG_CODE='||:Parameter.Org_Code;
        End if; -- specific routing
        Fnd_Function.Execute(
          function_name => X_Function,
          open_flag => 'Y',
          session_flag => 'Y',
          other_params  => X_Parameters);

  • Working on Pre-query

    Hi Gurus,
    While using a pre-query,can data of more than one field be passed from control-query to display-query?
    How can we do that?
    Thanks in advance
    Walker

    A prequery is usually used to send back filter values to another query based on comples selection conditions - I am not sure if a prequery can return multiple fields - even if it did - the replacement path variable is attached to a characteristic and in that case only the relevant characteristic should get passed on.
    Arun

Maybe you are looking for