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'.

Similar Messages

  • Change background color in enter-query mode

    Hi everyone,
    I am trying to Change background color in enter-query mode in forms10g. I am using this
    Set_Item_property('org.branch_code', BACKGROUND_COLOR, 'Green' );
    Thanks

    This is the code that allows to colorise items in enter_query mode, then de-colorize them after execute_query.
    Assume that you have created a VA_QUERY visual atribute in your module.
    -- Colorise in enter-query mode --
    PROCEDURE Start_query IS
      LC$Block      Varchar2(30) := Name_in('system.trigger_block') ;
      LC$item       varchar2(60);
      LC$itemdeb    varchar2(60);
      LN$len        pls_integer ;
    BEGIN
      lc$itemdeb := get_block_property(LC$BLOCK, FIRST_ITEM) ;
      lc$item := LC$BLOCK || '.' || lc$itemdeb ;
      while lc$itemdeb is not null Loop
        IF GET_ITEM_PROPERTY(LC$Item , ITEM_TYPE) NOT IN ('BUTTON','RADIO GROUP','DISPLAY ITEM') Then
          IF GET_ITEM_PROPERTY(LC$Item , QUERYABLE ) = 'TRUE' Then
            set_item_property(LC$item, CURRENT_RECORD_ATTRIBUTE, 'VA_QUERY');
          End if ;
        End if ;
        lc$itemdeb := get_item_property( lc$item, NEXT_NAVIGATION_ITEM );
        lc$item := LC$BLOCK || '.' || lc$itemdeb ;
      end loop ;
    END;
    -- Unclororize after execute_query --
    PROCEDURE End_query IS
      LC$Block     Varchar2(30) := Name_in('system.trigger_block') ;
      LC$item     varchar2(60);
      LC$itemdeb     varchar2(60);
      LN$len          pls_integer ;
      LN$Multi  pls_integer ;
    BEGIN
      lc$itemdeb := get_block_property(LC$BLOCK, FIRST_ITEM) ;
      lc$item := LC$BLOCK || '.' || lc$itemdeb ;
      LN$Multi := GET_BLOCK_PROPERTY(LC$Block , RECORDS_DISPLAYED ) ;
      while lc$itemdeb is not null Loop
        IF GET_ITEM_PROPERTY(LC$Item , ITEM_TYPE) NOT IN ('BUTTON','RADIO GROUP','DISPLAY ITEM') Then
          IF GET_ITEM_PROPERTY(LC$Item , QUERYABLE ) = 'TRUE' Then
             If LN$Multi > 1 Then
                set_item_property(LC$item, CURRENT_RECORD_ATTRIBUTE, 'VA_CURRENT_RECORD');
             Else
                set_item_property(LC$item, CURRENT_RECORD_ATTRIBUTE, '');
             End if ;
          End if ;
        End if ;
        lc$itemdeb := get_item_property( lc$item, NEXT_NAVIGATION_ITEM );
        lc$item := LC$BLOCK || '.' || lc$itemdeb ;
      end loop ;
    END;Francois

  • Prevent interpretation of special characters in enter-query mode

    My problem goes as follows:
    - forms version: Forms [32 Bit] Version 6.0.8.10.3 (Production)
    - non-database item block.X, char
    - block.X is filled in post-query trigger. The post-query logic cannot be integrated in a view because it uses procedures, and usage of a pipelined function + view is currently not allowed due to "internal restrictions". Put simply: all logic to fill the field must remain in the post-query trigger
    - user wants the field to be queryable. This is achieved by storing the entered criterium in a variable in the pre-query trigger, and using it in the post-query trigger to exclude records. E.g.
    pre-query ==> help_block.query_X := block.X;
    post-query ==> if help_block.query_X is not null and block.X is null or not block.X like help_block.query then raise form_trigger_failure; end if;
    - this works fine for "regular" search strings. However:
    - whenever the search string starts with <, <=, >, >=, !, forms seems to interpret the leading characters before doing anything else. During pre-query, block.X is null, and as soon as I use it in pl/sql, I get FRM-40831: Truncation Occured: value too long for field. E.g.
    user puts the following in block.X ==> '<X', so he wants to search for records with value '<X' (text; not 'smaller than ...')
    pre-query => msg.show(block.X) ==> appears to be empty/null, but right after the message, I get FRM-40831 Truncation Occured: value too long for field ...
    This only happens if < is the first non-space character in the search string.
    Does anyone know of a way to prevent oracle from interpreting the <, <=, ... characters entered in enter-query mode?

    I'm sorry for not making myself clear; I'll give it another go:
    The problem is that, if I enter '<abc' in a form field in enter-query mode (so during creation of the "example record"), forms immediately interprets the < as 'smaller than' and does some obscure things with it (my guess: converting to a where clause, but since I'm using a non db field, this actually does nothing), and finishes by erasing the field contents (in the example record). In the pre-query trigger, I can no longer get the '<abc' and store it. I want one of the following:
    - prevent forms from interpreting the '<' in front (same thing happens for !=, <=, >=, =, ...)
    or
    - capture the entered string ('<abc') before forms reacts to the '<' in front
    Edited by: [email protected] on Feb 17, 2009 12:30 PM

  • Blocking some fields from entering in summary block in enter query mode

    Hi ,
    I have a data block where in some fileds have to be dynamically allowed to enter and some are not based on
    a particular condition. The problem is whenever the forms enters enter query mode, all the fileds in the block are updateble. Even maually I tried to set/unset the property in forms using set_item_property, but the enter query mode was trying to overiride it and making updateble.
    Please suggest a solution for this.
    Thanks in advance.
    Thanks,
    Lohith

    Try the below code
    IF  :SYSTEM.MODE='ENTER-QUERY' THEN
    SET_BLOCK_PROPERTY('BLOCKNAME',INSERT_ALLOWED,PROPERTY_TRUE);
    SET_BLOCK_PROPERTY('BLOCKNAME',UPDATE_ALLOWED,PROPERTY_TRUE);
    SET_BLOCK_PROPERTY('BLOCKNAME',DELETE_ALLOWED,PROPERTY_TRUE);
    you can set the item here too by using the below code
    SET_ITEM_PROPERTY('BLOCK.ITEM_NAME',INSERT_ALLOWED,PROPERTY_TRUE);
    SET_ITEM_PROPERTY('BLOCK.ITEM_NAME',UPDATE_ALLOWED,PROPERTY_TRUE);Regards
    Moazam
    Edited by: Moazam Shareef on Oct 6, 2010 6:10 AM

  • Open multiple forms, few in Enter-Query mode

    Hi All,
    I want to open multiple forms from a form using open_form built-in. If user clicks on different items of the parent form different child forms are invoked.
    But if one child form is opened in Enter-Query mode (I have 'enter_query;' in its when-new-form-instance) it does not allow to put focus back on parent form and invoke other forms until I execute_query in child form or close the child form.
    Waiting for your replies. Thanks in advance.
    Regards
    Mona

    Hi Friends,
    Has anybody ever faced this problem. Please reply.
    Regards

  • [ 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

  • Forms that start in enter query mode freeze on exit

    When a headstart form is called from
    a menu and the first thing it does if go into
    enter query mode the form will not exit properly, causing the orginal form to hang.
    Is there any work around for this apart from taking enter_query out of the when_new_form_instance trigger ?

    We have a similar problem with a Headstart generated application. We are unable to pinpoint it entirely to forms that start in enter query mode as:
    a) forms that don't start in enter query mode also hang; and
    b) not all forms that start in enter query mode do hang.
    The problem doesn't seem to affect a form consistently, as one day it will hang on the first use, the next it will work for several hours.
    When a new form is selected from the menu the toolbar is not shown, the 'start' form disappears and the application hangs. It is then necessary to close the application using Task Manager.
    The good news is that this only seems to happen in our development environment (Windows NT 4) and not in our live environment (Hydra).
    We are working with Headstart v2.1.2.0.1,
    Designer v2.1.24.1.0 and Forms v5.0.6.11.0.

  • Do_Key in Enter-Query mode

    Hello,
    I have a WHEN-BUTTON-PRESSED trigger that has do_key('list_values') that brings a calendar. I use calendar.pll library. It works, when the system is in normal mode. But when the system is in enter-query mode it does not work. It says "Function key not allowed". What is the alternate solution, other than calling the calendar functionality from a new form?
    Thanks in advance.
    Arun.

    try this out,
    go_item('item_name');
    execute_trigger('key-listval');
    specify the item name for go_item

  • Starting form in Enter-Query mode disables some buttons on Smartbar

    Whenn I run a form (on the Web) which starts in Enter-Query mode, the buttons "Execute Query" and "Enter Query" are disabled on the Smartbar. Also the corresponding menu options are disabled. Besides, it is psossible to use the appropiate keys (in my case: F7 and F8).
    Has anyone experienced the same problem and is there a solution?
    Let me know.
    Thanx

    Frank: Thats what i thought too -but i saw (in other Sources) that it could be done, but how..
    Eugeniy I Duzhinskiy:
    So, many Thanks to you. It works fine !!!!
    (Its great to see there are some other Forms Users out there :) )

  • Calendar in Enter-Query Mode

    Dear All ,
    i hv posted my problems before.
    My. Calendar does not work in Enter-Query Mode.
    It says 'Function Key Not Allowed' It's Because of the Code(Go_Block) in Get Date procedure in the date package.
    Any Suggestion on this will be highly appreciated.

    You will have to change the calendar code to reside in a separate Form and use CALL_FORM to pop it up. This will be valid in Enter-Query mode - You'll then pass the selection back in a Global variable.

  • 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

  • KEY-CERREC TRIGGER IN ENTER-QUERY MODE

    hi all,
    i want fire key-crerec trigger in enter-query mode, how it can be done.
    i am using oracle 10g r2.

    first: Why did you need such a trigger? In Enter-Query-Mode it is impossible to create new records.
    second: Forms has a problem with some triggers in some modes. That means, that some trigger didn't fire in enter-query, but in older versions of forms they do. So, maybe you run into one of this problems

  • 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 to exit from Enter-Query mode

    Hi
    I am not being able to exit from the Enter-Query mode if the result set is not returned.
    I tried to exit using ABORT_QUERY, exit_form( as we used to do in earlier version) and CTRL+Q. Nothing seems to work and I have to kill the form
    This seems to be an easy topic, but I need your help.
    Thanks in advance
    Bijay

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by bj ():
    Hi
    I am not being able to exit from the Enter-Query mode if the result set is not returned.
    I tried to exit using ABORT_QUERY, exit_form( as we used to do in earlier version) and CTRL+Q. Nothing seems to work and I have to kill the form
    This seems to be an easy topic, but I need your help.
    Thanks in advance
    Bijay<HR></BLOCKQUOTE>you maybe include a not null item,you can set the item's property
    not need .
    null

Maybe you are looking for