Entering query criteria in an item(s)

Hi. In have what I hope is an easy question...
In the same way a user can enter the % character in an item on the canvas to query records where the column is Not Null, can the user enter some special character in the item that will query only records where the value is null?

Hi There:
Try this, it works for me.
Add the block trigger called PRE-QUERY with the following code:
DECLARE
     VV_DEFAULT_WHERE VARCHAR2(500);
BEGIN
     IF :AEMS_PRUEBA.PHONE = '!'
          THEN
          :AEMS_TEST.PHONE := NULL;
          VV_DEFAULT_WHERE := 'AEMS.SEQ IN (SELECT P.SEQ FROM AEMS_TEST P WHERE NVL(P.PHONE, ''!'') = ''!'')';
          SET_BLOCK_PROPERTY('AEMS_TEST', DEFAULT_WHERE, VV_DEFAULT_WHERE);
     END IF;
END;
In the above code, yo can see I am modifuying the defaul_where of the based-table block. The block is called 'AEMS_TEST'.
To do this, I create a local variable called VV_DEFAULT_WHERE. I use an If statement to ask for the special character you want to search for, in my test I ask for the '!'. If the the filed :AEMS_TEST.PHONE = '!' then I do the following:
I nullify the field :AEMS_TEST.PHONE. Then add the where condition the block will use to retrieve the information form the database, as you request retrieving all the records in the table which are equal to null but using a special character instead of living null the field on the block, so I wrote the following code:
VV_DEFAULT_WHERE := 'AEMS.SEQ IN (SELECT P.SEQ FROM AEMS_TEST P WHERE NVL(P.PHONE, ''!'') = ''!'')';
Where AEMS.SEQ is the field on the block [AEMS is the alias of the block]
after that, just need to setup the new where clause of your based-table block with the following code:
SET_BLOCK_PROPERTY('AEMS_TEST', DEFAULT_WHERE, VV_DEFAULT_WHERE);
Then when your user press the F8 to execute the trigger, it will send to the database the following select statement:
SELECT AEMS.NAME,
AEMS.ADRESS,
AEMS.PHONE,
AEMS.LIMIT,
AEMS.SEQ
FROM AEMS_TEST AEMS
WHERE AEMS.SEQ IN (SELECT P.SEQ FROM AEMS_TEST P WHERE NVL(P.PHONE, '!') = '!'
Hope this works for you-
Abdel Miranda
AEMS Global Group
Panama

Similar Messages

  • Enter query - what was changed (entered) in enter query mode

    Hello,
    I need to know what criteria (values and items) an user entered (typed) when my form is in enter query mode.
    Thanks

    You can read about Pre-Query trigger in the Forms on-line help:
    About controlling queries with Pre-Query and Post-Query triggers
    The Pre-Query and Post-Query triggers allow control over query processing. They can be defined at the form or block level. Most often, attach them to specific blocks to control the query functionality of those blocks.
    The Pre-Query trigger fires just before Form Builder issues the SELECT statement to the database, after the operator has defined the example record by entering query criteria in Enter Query mode.
    Inside a Pre-Query trigger, the example record defined by the query criteria is the current record. This means that trigger code can read and set the values of items in the example record using standard :block_name.item_name syntax.
    A Pre-Query trigger can be used to disallow query conditions that might be invalid. When a form is in Enter Query mode, normal validation is suspended and no validation triggers fire as they do in Normal mode. The Pre-Query trigger thus allows you to verify that any values entered by the operator are valid query conditions.
    When invalid query conditions have been entered, you can abort the query by raising the FORM_TRIGGER_FAILURE built-in exception in the Pre-Query trigger.
    You can also call SET_BLOCK_PROPERTY to modify the block's WHERE and ORDER BY clauses from within the Pre-Query trigger, to further restrict or order the records the query will retrieve.
    I hope this will help you.
    Helena

  • How use enter query what writh in enter_query button

    hi master
    i hae three text box dept block and other in emp block table such as
    in dept block
    deptno
    dname
    loc
    i have three button
    enter_query
    execute_query
    exit
    if my user put 20 in dept.deptno and press then enter_query button
    and press execute_query button
    please give me idea what i write in enter_query button
    thanking You
    Aamir

    You can read about Pre-Query trigger in the Forms on-line help:
    About controlling queries with Pre-Query and Post-Query triggers
    The Pre-Query and Post-Query triggers allow control over query processing. They can be defined at the form or block level. Most often, attach them to specific blocks to control the query functionality of those blocks.
    The Pre-Query trigger fires just before Form Builder issues the SELECT statement to the database, after the operator has defined the example record by entering query criteria in Enter Query mode.
    Inside a Pre-Query trigger, the example record defined by the query criteria is the current record. This means that trigger code can read and set the values of items in the example record using standard :block_name.item_name syntax.
    A Pre-Query trigger can be used to disallow query conditions that might be invalid. When a form is in Enter Query mode, normal validation is suspended and no validation triggers fire as they do in Normal mode. The Pre-Query trigger thus allows you to verify that any values entered by the operator are valid query conditions.
    When invalid query conditions have been entered, you can abort the query by raising the FORM_TRIGGER_FAILURE built-in exception in the Pre-Query trigger.
    You can also call SET_BLOCK_PROPERTY to modify the block's WHERE and ORDER BY clauses from within the Pre-Query trigger, to further restrict or order the records the query will retrieve.
    I hope this will help you.
    Helena

  • Unable to find Searchable Item in Query Criteria Map

    Hi ,
    Am try to personalize Advacned Search Region to Include new search Criteria in R12 iSupplier Portal->Home->Orders Tab->Advanced search.
    Am trying to create new search field in the Add another row field through personalization.
    I have created new row criteria,when am trying to create Query Criteria Map,Am unable to list the Searchable Item as it is Drop down list.
    This causing unable to query the records based on the newly created row criteria item.
    Please advise.
    Thansk<Sarath.

    Hi Jobnish,
    There is no code in this requirement.
    There is no error...Issue is unable to query data based on newly create criteria row in Advanced search.
    I can give you navigation:
    iSupplier Portal->Home->Orders Tab->Press advanced search Region
    Click on the Personalize Page(I hope you know how to enable the personalize link using profile option).
    In SupplierRN ->Advanced Search Criteria and creating custom item Criteria Row..
    We need to map this field in Advanced Query Mapping.
    However the issue is the Am unbale find the Searchable item (which is created in Criteria Row) in the drop downlist.
    I can provide screen-shot if you need.
    Thanks,Sarath.

  • Cursor remaining in the current item even after pressing Enter-Query

    We have an application running in 10g.
    We are getting similar problems in three forms of the application.
    In the form there are 2 datablocks which has a master-detail relationship.
    After the data for the first datablock is retreived, when I click on any of the items and give enter-query, the cursor remains in the same item.
    Ideally the cursor should move to the first item in the datablock after entering the enter-query mode. But it is not happening.
    This is working fine in the other forms. When i give enter-query, the cursor is going back to the first item.
    Only in these three forms, it is behaving differently.
    Expecting a quick reply...

    did you check if the items in object navigator have the same order as on canvas?
    in normal case the cursor goes to the first enterable item in block when entering in query mode.
    as workaround you can write your own KEY-ENTQRY trigger:
    ENTER_QUERY;
    GO_ITEM('YOUR_BLOCK.YOUR_ITEM');

  • [ Forms10g2 ] Default item value in Enter-Query mode

    Hello!
    How could I specify default value for an item in Enter-Query mode? E.g. I press KEY-ENTQRY, and :L_YEAR item gots current year as a default search condition (though it may change). I've tried to implement it this way:
    <pre>
    Enter-Query;
    :l_year := extract(year from sysdate);
    </pre>
    This work in a rather awkward way. If I run this once (e.g. as a result of a hotkey press), it just enters Enter-Query mode, but if I run this twice (by pressing hotkey second time) it fills :year variable and does search with it as a search condition! Then, I've tried to go straight and wrote:
    <pre>
    Enter-Query;
    :l_year := extract(year from sysdate);
    Enter-Query;
    :l_year := extract(year from sysdate);
    </pre>
    Well, this didn't work. And SYNCRONIZE call before the second Enter-Query didn't help either. So, my questions are: 1) how can I achieve needed behaviour? 2) What's going on in my experiments? Why :L_YEAR gets assigned on second keypress (as in first experiment) but not on second subsequent call (as in second experiment)?
    Thanks in advance!

    I don't know why that won't work but I have something which might:
    when-new-record-instance trigger:
    if :system.mode = 'ENTER-QUERY' then
      :l_year := extract(year from sysdate);
    end if;It's always best to use both the block and item names...:block.l_year

  • Disableing an item in enter query mode

    Hello experts,
    i want that a perticular item will be disabled after you press enter button of query menu.(or query->enter).Can any body please tell me what is the actual trigger in which i write the disable statement.
    set_item_property('itemname', enabled, property_false);
    Regards
    Anutosh

    You can't set the enabled property if the cursor is in the item and I expect it's the same for the query_allowed property. if the cursor is in the item which you set to Query_Allowed=false and then you go to enter-query mode, perhaps forms doesn't know what item to move the cursor to, so just leaves it where it is.
    You can solve the problem by moving to a different item (with go_item) before setting the property.
    When do you need to set the item back to enabled? If you want it enabled at all times other than when a query is being entered then use the Property Pallet to set the Query Allowed property. If you want to disable the field under certain conditions then the when-new-record-instance trigger might be better for you. Eg
    if :system.mode = 'ENTER-QUERY' and <condition> then
      go_item(<another item>);
      set_item_property(<item>, enabled, property_false);
    else
      set_item_property(<item>, enabled, property_true);
      set_item_property(<item>, update_allowed, property_true);
      set_item_property(<item>, navigable, property_true);
      set_item_property(<item>, update_null, property_true);
    end if;It might be better to set the query_allowed property instead of the enabled property, but I can't check right now whether that's possible after the enter-query mode has begun.
    The update_allowed, update_null and navigable properties are all set to false as a consequence of the enabled property being set to false. If they should be true then you need to reset them after reenabling the item.

  • Non-Database items in enter-query mode

    I have a form with 2 base table blocks, typical master details situation. I wish to allow a field from the detail block to be queryable from the master block. I was considering adding a non-database item to the master block (visible only when in Enter-Query mode). In a pre-query trigger I would amend the DEFAULT-WHERE property of the master block when the appropriate where clause using the non-database item value. My prototype/test version works fine except the non-database item is not enabled while the master block is in enter-query mode.
    I think basically forms will enable only field s if they are database items and queryable set to yes. There are no more database items I can use to set the non-database item column name property.
    Any suggestions would be appreciated.
    Ralph
    Oracle Developer - Unisys Australia

    Hi Ralph,
    we have several Forms using non-database items as query-items which works fine.
    What we did is following:
    1) create non-database item xy in master-data-block
    2) set property database item to no
    3) set property query allowed to yes
    4) create a pre-query trigger on master-data-block where we change the where-clause (this is forms6i, in 9i we would use the one-time-where-clause)
    Peter

  • Clearing items upon hitting "Enter Query"

    I have a detail block with 5 fields in each record. There are five non-database items on the form to display the current record in this detail block. Upon moving the cursor to a different record in the block, the new record's fields are displayed in these non-database items.
    What is required is that upon hitting "enter query" on this detail block, these non-database item fields become cleared also.
    Any thoughts would be appreciated.
    Ammar

    this approach is not recommended as I think that these built-ins cause problems on some platforms (the go_block built-in)Never heard of such problems. If thisis so, then no forms-application would run on that platform, for forms also uses GO_BLOCK for master-details-relationships.
    The easiest way to achieve your functionality (without any coding) would be to do the following:
    Delete your second datablock with the non-database-items.
    Duplicate the items in the databaseblock you want to show in a detail-area.
    Set No. of tems displayed to 1 on these items.
    Move the items in the layout to the desired position.
    Set the poperty "Synchronize with" for each item so that it matches the item it should get the value from.
    Thats all.

  • New item position for cursor after enter query

    I am trying to have my cursor being reposition in a different item once I click on enter query mode. For some reason, it will not go there. I have the following code in the key-entqry trigger
    go_item('cust.custno');
    enter_query;
    it will not go there till I do a cancel query which is no good.
    Please help,
    Joe

    Hi,
    Try this in the When-new-record-instance trigger of the 'CUST' block:
    if name_in('system.mode') = 'ENTER-QUERY' then
         go_item('cust.custno');
    end IF;
    Hope this helps you,
    Regards,
    CB

  • Display Item cleared when using 'Enter-Query'

    Hi all,
    i am going to develop a multilanguage application with very
    special heading texts using display items for these headings.
    BUT- if I press EnterQuery, they are cleared also.
    How can I restrict cleanup of these display items used as
    headings ?
    I was looking in the properties, but no idea.
    Thanks for help,
    udo

    I'm showing how to do it when switching modes. I'm
    not suggesting this is the best way to do a query.We need to look at this in the context of the original probelm in the thread linked to above. For most cases the when-timer-expired etc is just a huge detour around using the pre-query trigger but it's an interesting approach to the specific problem in the earlier thread. The OP there wanted to be able to type '>5000' into a number field in a non-database block, which we can do in a database block in enter-query mode, and use it as a query parameter in the database block. Perhaps if we enter this into a character field in the non-database block and populate the numeric field in the database block whilst in enter-query mode then we can do searches on ranges of data? Unfortunately it doesn't work - you get an ora-06502 error just like you do when using the pre-query trigger. For the situation in the original thread you would have to use a 'default where'.

  • Changing visual attribute in Enter Query mode

    Hello, I want to change visual attribute of all items in the first record when the user presses button for Enter_Query. I want that the user sees that the form is in enter query mode and it "waits" for the input of criteria. My code (copied from Help and modified) in trigger WHEN_BUTTON_PRESSED:
    DECLARE
    cur_itm VARCHAR2(80);
    cur_block VARCHAR2(80);
    BEGIN
    ENTER_QUERY;
    cur_block := :System.Cursor_Block;
    cur_itm := Get_Block_Property( cur_block, FIRST_ITEM );
    WHILE ( cur_itm IS NOT NULL ) LOOP
    cur_itm := cur_block||'.'||cur_itm;
    Set_Item_Instance_Property( cur_itm, CURRENT_RECORD, VISUAL_ATTRIBUTE,'yellow');
    cur_itm := Get_Item_Property( cur_itm, NEXTITEM );
    END LOOP;
    END;
    where yellow is the name of my visual attribute.
    The problem is that I need to press the button TWICE to color the record.
    Can anybody help me with this problem?
    Natasa

    (Wrong forum).
    The problem is that enter_query stops executing your procedure until
    another action ist started by the user.
    You must create a short-time timer before issuing enter_query and set
    your colour scheme in the when-timer-expired-trigger.

  • Entering selection criteria in different blocks at the same time

    I want to create a form based on a master-datail-relationship in which the user
    in enter-query-mode can specify selection criteria in the master AND the detail
    block at the same time before executing the query.
    How can I achieve this ?
    Thanks in advance
    STD

    Create a control block with the items you want to query on. After the user presses the execute_query button or whatever to execute the query have the code :
    do_key('execute_query');
    In the KEY-EXEQRY trigger :
    declare
    where_cl_mas varchar2(1000);
    where_cl_det varchar2(1000);
    begin
    where_cl_mas := ' ';
    where_cl_det := ' ';
    if :item1 is not null then
    where_cl := where_cl&#0124; &#0124;'col1 = '&#0124; &#0124;:item1&#0124; &#0124;' and ';
    end if;
    continue like this for the master block items.
    Then continue like this for the detail block with the where_cl_det block.
    After creating the where clauses :
    where_cl_mas := substr(where_cl,1,length(where_cl_mas)-5); --- to strip off the last ' and ' from the statement.
    Do the same with where_cl_det too.
    Then
    set_block_property(master_block, default_where, where_cl_mas);
    set_block_property(detail_block, default_where, where_cl_det);
    execute_query;
    See if this works for you.

  • Using Enter-Query Mode Programmatically

    A question was raised in an earlier thread
    QUERY CRITERIA MANAGER
    about how to use Enter-Query mode programmatically in a way that doesn't stop
    and prompt the user to enter a query after switching from Normal mode to Enter-Query mode.
    Since the solution may not be widely known, I thought I'd demonstrate the technique here in a new thread.
    Create a simple form with just two blocks. Using the data block wizard, create an EMP block with one
    text item for ENAME. Place it on the canvas. Create the other block as a control block and name it CONTROL.
    Inside the control block create the following items:
    - create a text item named TXT_BOX
    (The user will enter their search pattern criteria in this text box while in Normal mode.)
    - create a push button item named EXECUTE_QUERY
    (This button will switch to Enter-Query mode, execute the query, then return to Normal mode.)
    Place both control items on the canvas.
    Inside the WHEN-BUTTON-PRESSED trigger for the EXECUTE_QUERY button, enter the following code:
    DECLARE
         timer_id TIMER;
    BEGIN
         :GLOBAL.search_criteria := :CONTROL.TXT_BOX;
         GO_BLOCK('EMP');
         timer_id := CREATE_TIMER('ENT_QRY', 1500, NO_REPEAT);
         -- 1500 may be a little long, but provides a margin of error
         ENTER_QUERY;
    END;
    Next, create a WHEN-TIMER-EXPIRED trigger at the form level. Inside this trigger enter the following code:
    If GET_APPLICATION_PROPERTY(TIMER_NAME) = 'ENT_QRY' THEN
         :EMP.ENAME := :GLOBAL.search_criteria;
         EXECUTE_QUERY;
         IF :SYSTEM.MODE = 'ENTER-QUERY' THEN
              EXIT_FORM; -- return to Normal mode
         END IF;
    END IF;
    GO_ITEM('CONTROL.TXT_BOX');
    Now, when the user runs the form and logs into the SCOTT schema, he enters a search criteria
    such as A% in the TXT_BOX while in Normal mode. Then clicks the EXECUTE_QUERY button.
    The form will switch to Enter-Query mode, retrieve all names in ENAME that begin with the letter A,
    and then return to Normal mode without pausing for the user to enter a search criteria.
    If the query should happen to fail, the form displays the error:
    "FRM-40301: Query caused no records to be retrieved. Re-enter."
    then switches automatically back to Normal mode so the user can try entering a new criteria.

    I'm showing how to do it when switching modes. I'm
    not suggesting this is the best way to do a query.We need to look at this in the context of the original probelm in the thread linked to above. For most cases the when-timer-expired etc is just a huge detour around using the pre-query trigger but it's an interesting approach to the specific problem in the earlier thread. The OP there wanted to be able to type '>5000' into a number field in a non-database block, which we can do in a database block in enter-query mode, and use it as a query parameter in the database block. Perhaps if we enter this into a character field in the non-database block and populate the numeric field in the database block whilst in enter-query mode then we can do searches on ranges of data? Unfortunately it doesn't work - you get an ora-06502 error just like you do when using the pre-query trigger. For the situation in the original thread you would have to use a 'default where'.

  • [Solved] Problem with LOV and 'enter query' mode

    Hi all,
    I'm kind of new to Forms and I'm having some problems that I'm not being able to resolve. I already search it on the net, but nothing relevant came up. If anyone could help me I appreciated it.
    In my form I have some fields, and in one of them I have a LOV, and almost everything works fine. I inserted data, changed it, deleted it and all it's ok.
    But when I change to 'enter query' mode, when I try to search for data on the LOV field it ignores what I write.
    That is, for it, it's the same if I make F11 -> write 'aaaa' -> ctrl + F11 or if I make F11 -> '%' -> ctrl + F11.
    It behaves the same way, shows me all the records.
    Probably I'm missing something basic, but I'm not getting it...
    Thanks,
    Ana

    when you create a lov by wizard the lov and record group have always the same name..
    the problem is that the item is NOT based in the tabe.
    what kind of query do you execute if you choose something from a love which is not based on the db?
    i mean, this item has no influence on the query of the table, so whatever you choose it's like a "select * from table"
    i hope i was clear

Maybe you are looking for