Execute query in control block?

I have a non database block which is the control block. In this block i have a button for query/ enter query. My other blocks are all based on a database table. So when i run the form and press the exec query button, on the control block, i want to be able to select something from an lov, or a drop down or even a text item which are located on any of the other blocks. and then hit the exec query button again to query the specific information.
But its not working. i can't seem to get the exec query button to work in the control block and i tried placing it on one of the blocks but i can only select from that block to query on and not any of the other blocks.
how can i get the exec query button to work on any of the other blocks depending on what i want to query up?

You will have to build a default where clause in the pre query trigger of the base table block(s)
example shown below.
declare
wh_clause varchar2(1500);
begin
if :qry_blk.item1 is not null then
     wh_clause := 'block.item1 like '''||:qry_blk.item1||'%'||'''';
end if;
set_block_property('block', DEFAULT_WHERE, wh_clause);
end;
then in your button, you will say
go_block('block');
execute_query;          
I have a non database block which is the control block. In this block i have a button for query/ enter query. My other blocks are all based on a database table. So when i run the form and press the exec query button, on the control block, i want to be able to select something from an lov, or a drop down or even a text item which are located on any of the other blocks. and then hit the exec query button again to query the specific information.
But its not working. i can't seem to get the exec query button to work in the control block and i tried placing it on one of the blocks but i can only select from that block to query on and not any of the other blocks.
how can i get the exec query button to work on any of the other blocks depending on what i want to query up?

Similar Messages

  • Can execute query be controlled for blocks

    Hi,
    I've 3 blocks in my form. The first and the second block are in query mode, therefore I cannot update, insert, delete values here.
    The third block, I have put on another canvas. So the moment there's data in the second block the third block gets displayed. The user is allowed to enter values only in the third block.
    Since the first and second block are in query mode I've put the execute_query in the W-N-F-I.
    Due to the execute_query in W-N-F-I the 3rd block also starts showing me values, which it shouldn't. It should be a clear block with no values displayed.
    Mainly I want the execute_query to work only for first and second block and not for the third block.
    I tried putting the execute query in pre-block trigger. But it showing me error as Illegal operation for join condition and the forms gets hanged.
    Kindly if you could help on the same
    Thanks for your help in adv.

    I'm not sure I completely understand what you are attempting.
    I've 3 blocks in my form. The first and the second block are in query mode, therefore I cannot up date, in sert, de lete values here.So, for BLOCK1 and 2 you have set the "Query Only" property for each block item to "yes". BLOCK3 allows all DML operations.
    Since the first and second block are in query mode I've put the execute_query in the W-N-F-I.Since, these blocks are Query Only, you automatically query them in the WNFI trigger.
    Due to the execute_query in W-N-F-I the 3rd block also starts showing me values, which it shouldn't. It should be a clear block with no values displayed.Here is where I'm a little confused. Do you have a block Relationship created with BLOCK3 or do you call Execute_Query on BLOCK3 in your WNFI trigger?
    I tried putting the execute query in pre-block trigger. But it showing me error as Illegal operation for join condition and the forms gets hanged.Which data block did you try the Pre-Block trigger? By definition, the Pre-Block trigger does not allow the execution of Restricted built-ins. The Execute_Query built-in is Restricted.
    So the moment there's data in the second block the third block gets displayed. The user is allowed to enter values only in the third block.How did you implement this? What is the code you use to display BLOCK3's canvas?
    So, what happens if you have records in BLOCK3 that relate to a record in BLOCK2? How will your user know this if you start with an empty block? I've confused by the description of your requirement...
    Craig...

  • Which block get effected by save and execute query

    Hello,
    I'm using forms 9i , database oracle 9i.
    Case:
    i made a simple application with 4 stack canvas on each i place data from 4 tables. convention is like every stack canvas get visible when the corresponding button is pressed. once visible i don't set it to invisible i just place other stack canvas over it.
    Although i don't get any error or problem while doing normal work like saving records or Executing query. but i don't understand whether these operation only effect the table which is visible(on stack canvas). and rest of are unaffected.
    if No then how i can do it with only on visible canvas
    and if yes is there any way that i can do execute query on all of them.
    thanks
    Rahul.

    The SAVE (COMMIT_FORM or COMMIT) will affect the whole form if you are using simple blocks based on tables, every block that does have changed or new data it will saved in the database.
    The EXECUTE_QUERY will affect only the current block, the block where the cursor is in currently. If this block is a master block then the EXECUTE_QUERY on the master block will also affect the detail block.
    If it's a standalone (not a master) block, the EXECUTE_QUERY will only affect the block your cursor is in.
    Tony

  • Problem in Execute query on non-database block and database block together

    Hi All,
    In my form,i have
    1. First block is Non-database block with one non-database item.
    2. Second and third blocks are database blocks.
    Now the problem is that i want to perform execute-query for all the blocks.
    If the cursor is on the non-database item of 1st block and i clicks on the "Enter-query" then i am getting message " This function can not be performed here".
    If i click on the item of the database block and then clicks on the "Enter-query" and then "execute-query" it's working fine.
    But i don't want to do in this way.
    My cursor will be on the First block only and then it should perform execute-query.
    I am using this non-database item to copy value of this item to the item of the database block item.
    I think i make you understand about my problem.
    I am using forms 10g on Window xp.
    Please help me.

    Hi!
    Simply create a enter-query trigger on the non-database-block:
    begin
    go_block ( 'database_block' );
    enter_query;
    end;If your search criteria is in the non-database-item in the first block,
    you actually do not need the enter_query build-in.
    Just create a execute-query trigger on the first block like:
    begin
    go_block ( 'database_block' );
    execute_query;
    go_item ( :System.trigger_item );
    end;And in a pre-query trigger on the database-block copy the
    value of your seach item into the item you want to search for.
    Regards

  • Execute query with non database block

    How to execute query with non database block when new form instance trigger.

    Hi Kame,
    Execute_Query not work with non database block. To do this Make a cursor and then assign values to non database block's items programmatically, see following example,
    DECLARE
    BEGIN
         FOR i IN (SELECT col1, col2 FROM Table) LOOP
                :block.item1 := i.col1;
                :block.item2 := i.col2;
                NEXT_RECORD;
         END LOOP;
    END;
    Please mark if it help you or correct
    Regards,
    Danish

  • WHEN-TREE-NODE-SELECTED need 2 Execute-Query on Master-Detail data block

    I optimize tree using this link
    http://andreas.weiden.orcl.over-blog.de/article-29307730.html_+
    For huge amount of data (Accountings)
    All i need for now is
    WHEN-TREE-NODE-SELECTED need 2 Execute-Query on the data block
    DECLARE
    htree ITEM;
    node_value VARCHAR2(100);
    BEGIN
    IF :SYSTEM.TRIGGER_NODE_SELECTED = 'TRUE' THEN
    -- Find the tree itself.
    htree := FIND_ITEM ('BL_TREE.IT_TREE');
    node_value := FTREE.GET_TREE_NODE_PROPERTY( htree, :SYSTEM.TRIGGER_NODE ,  ftree.node_value  );
       GO_BLOCK ('GL_ACCOUNTS');
       set_block_property('GL_ACCOUNTS', DEFAULT_WHERE , 'ACCOUNT_ID ='|| node_value  );
    EXECUTE_QUERY;
    END IF;
    END;The above code is working fine 4 the detail block which is *'GL_ACCOUNTS'*
    when i substitute is Master block which is 'GL_ACCOUNTS_TYPES' it doesn't display all data
    Help is Appriciated pls.
    Regards,
    Abdetu...

    Hello
    In WHEN-TREE-NODE-SELECTED i modified the following code :_
    DECLARE
            htree ITEM;
           node_value VARCHAR2(100);
           parent_node FTREE.NODE;
    BEGIN
      IF :SYSTEM.TRIGGER_NODE_SELECTED = 'TRUE' THEN
      -- Find the tree itself.
      htree := FIND_ITEM ('BL_TREE.IT_TREE');
      -- Get the parent of the node clicked on. 
                  parent_node := FTREE.GET_TREE_NODE_PARENT ( htree, :SYSTEM.TRIGGER_NODE );
           GO_BLOCK('GL_TYPES');
                set_block_property('GL_TYPES', DEFAULT_WHERE , 'TYPE_ID ='|| parent_node  );
                  EXECUTE_QUERY;
      -- Get the detail of the parent node
          node_value := FTREE.GET_TREE_NODE_PROPERTY( htree, :SYSTEM.TRIGGER_NODE ,  ftree.node_value  );
               GO_BLOCK('GL_ACCOUNTS');
               set_block_property('GL_ACCOUNTS', DEFAULT_WHERE , 'ACCOUNT_ID ='|| node_value  );     
                   EXECUTE_QUERY;
          END IF;
    END;
    FRM-40350 : Query caused no records to be retrieved but i have records in the data base ...!
    Well, Do u think that's because in ur package i retrieve only the detail block ?
    Regards,
    Abdetu...

  • Is it possible to update (=change) control block items in a query only form ?

    From Form.A we call Form.B with the parameter query_mode = query_only.
    This works fine.
    But in Form.B we have a non table block (=control block) with an poplist item.
    Allthough in query_only mode we like to change (it's not a real update cause it's control block) the poplist.
    But because of query_only mode this item is not updateable.
    Is there a workaround to make the poplist updateable in query_only mode ?

    Hi,
    It is not possible to change the BOX position using the Layout painter like changing windows position.
    You have change in the page Windows text elements only by changing their co ordinates.
    Regards,
    Anji

  • Execute query when post text item

    Anybody can help ?
    I create 2 block, first a data block and another is a control block with field customer_search field,
    after inputing customer id in search field on control block,
    I want to execute query.
    my code :
    set_block_property('customer',default_where,'custid=:control.customer_search');
    execute_query;
    error : frm-407 : illegal restricted procedure execute_query in post-text-item trigger.
    How to solve this problem ?
    notes: If I create one push button and put execute_query in there, every thing is fine.
    but the my user does not like that.
    Thank.

    hi,
    first of all change ur statement as
    set_block_property('customer',default_where,'custid='||:control.customer_search);
    means u must use pipe sign while using bind variable
    secondly
    u should use key next item trigger
    go_block(user desired item or block);
    --and then use this satemant
    clear_block(no_validate);
    execute_query(no_validate);
    i hope it wil slove ur peoblem if it will NOT then please acknowledge otherwise we will go for a other solution
    thanks
    imran
    manager IT
    www.masoodtextile.com

  • Enter / Execute Query

    I have a form where a patient ID is entered in the master block. This block is related to two other detail blocks in the same form.
    The user enter's a patiend ID. This ID is to be checked for validity against a ID table. Then the ID is checked against the master table to ensure a record for the patient has not already been entered. If the ID is valid and had not already been entered, the user continues in insert mode and fills in the rest of the details. If the ID record already exists, then the details of the record need to be loaded.
    I have got everything working except the last part. How do I automatically switch from insert mode to execute query mode with the ID entered if it already exists in the table ?

    I think it would be best to enter the ID in a control block. Master default where would be ID = :control.ID Then you can have a when-new-block-instance trigger on master:
    :system.message_level := '5'; -- hides 'query caused no records'
    execute_query;
    :system.message_level := '0';
    if :master.id is null then
    :master.id := :control.id;
    end if;

  • Tab pages which Database and Control Block.

    I have 3 tab pages, 1st and 2nd with database first block and 3rd page has a control block .
    When I query these Pages I only get one record display though it is a multiple record block with scroll.
    The only difference is that every pages contain multiple blocks with relationship created.
    If some one can help me to bring all the records when I execute the query through F8 key.
    Thanx
    Khan

    Create master detail relation this may help you

  • Clearing Form when changing from Insert Mode to Enter/Execute Query

    Morning folks,
    I need some help or pointers with a form I am working on. At startup, the form is in Insert mode. I am using Oracle Forms 9i.
    Goal: Clear the form with NO_VALIDATE when User enters an ID in Insert mode and clicks on the Execute Query button(DEFAULT&SMARTBAR Inbuilt Menu)
    The user can do two things when they first open the screen.
    Option 1: Enter the STUDENT_ID and press Tab
    Option 2: Enter the STUDENT_ID and press the Execute Query button (Part of the DEFAULT&SMARTBAR Inbuilt Menu)
    There is a When-Validate-Item trigger on STUDENT_ID to check if the Student ID already exists in the database. If it does, it gives an Error message saying "Student ID found. Please Query the record or enter a new Student ID". This is fine with Option 1.
    The problem arises with Option 2. When I Enter a Student ID in Insert Mode and (thinking I am in Enter Query mode) and press the Execute Query button, I get two messages:
    Message 1: "Student ID found. Please Query the record or enter a new Student ID"
    Message 2: Oracle message "Do you want to save the changes? Yes/No/Cancel.
    Is there a way to stop this *Message 2?*
    Here is what I have done to try and mitigate this situation. I have created a non database field and have called it clear_form.
    In When-Validate-Item I set the field clear_form = 1 when I encounter *Message 1*
    {code}
    if t_record_exists > 0 then
    set_alert_property('ALERT_ERROR',ALERT_MESSAGE_TEXT,'Student ID found. Please Query the record or enter a new Student ID');
    alert_button := show_alert('ALERT_ERROR');
    :clear_form := 1;
    end if;
    {code}
    By creating *Key-EXEQRY* Trigger at Form Level, I was hoping that it would just clear the form. I put some messages and its seems to me that *KEY-EXEQRY* is firing first and then the *WHEN-VALIDATE-ITEM*. Is there a way to have the *WHEN-VALIDATE-ITEM* trigger fire first?
    {code}
    if :clear_form is null then
    execute_query;
    else
    clear_form(no_validate);
    end if;
    {code}
    Thanks!
    Edited by: Roxyrollers on Sep 28, 2012 8:50 AM
    Edited by: Roxyrollers on Sep 28, 2012 9:45 AM

    Having the actual Student_ID column from the table is dangerous, since it is also the key to the student's data. What if the user properly executes a query, showing a student's data, and then wants to look up another student, so keys in the new ID. If he then presses Execute Query, the Form asks "Do you want to save your changes?"
    If the user presses Yes, the new ID becomes the previous student's key.
    It would be better if you put the student_ID field in a control block. Then, the user enters a Student_ID, and presses Execute Query, the query then populates the student's data in the Base Table block. In the B_T block, the actual Student_ID column should be hidden.

  • When-Validate-Item and Go_Block/Execute Query dilemma

    Hey there folks -- Probably not a surprise question on this forum. I did try to search for this and came up with a few posts but did not find any solutions. Hopefully, I was also doing the correct way to search on this forum. If this is a post for the nth time on this issue, I apologize.
    So, I have 2 blocks:
    1. Control Block that contains the STUDENT_ID field (Database Item = 'N')
    2. Database block that contains the STUDENT_ID field (Database Item = 'Y' and many other fields)
    My goal is do an Execute_Query if User enters the Student ID and either presses TAB or places the MOUSE in the database block and display the record if it exists. As we know, a Go_Block is not allowed in When-Validate-Item. So, I went one step further to "simulate" this. The problem is that I am still firing the Execute-Query when the record has already been retrieved. Here is what I have so far. So, the Key-Next-Item trigger works fine if User enters a Student ID and presses tab. It also works fine if User clicks on the STUDENT_BK as the When-New-Block-Instance trigger fires which in turn calls the Key-Next-Item. The problem occurs when after record has been retrieved and User clicks on control.student_id and then comes and clicks on the STUDENT_BK, the KEY-NEXT-ITEM trigger fires again.
    Suggestions or pointers would be more than welcome.
    Thanks!
    CONTROL.student_id.Key-Next-Item
      if :control.student_id is not null and :SYSTEM.BLOCK_STATUS != 'CHANGED' then
        next_block;
        clear_block(NO_COMMIT);
        execute_query;
      else
        show_alert('Please enter Student ID');
      end if;
    STUDENT_BK.When-New-Block-Instance
    go_item('control.student_id');
    do_key('next_item');

    Yeah... I wrote before I tried it out. The GET_ITEM_PROPERTY('ITEM', previousitem) didn't work the way I thought it did. After I posted that, I tried it out and it was a complete failure.
    I guess what I am thinking now, is in your STUDENT_BK block, do you only want to EXECUTE_QUERY if the :STUDENT_ID does not match the :CONTROL.STUDENT_ID? If that is true, then all you would have to do is to change your KEY-NEXT logic to include the
    if STUDENT_BK.STUDENT_ID != :CONTROL.STUDENT_ID then
      -- original logic
      go_item('control.student_id');
      do_key('next_item');
    end if;The more I think about it, this should work for you. You said that you had two requirements: Entered a student id in the control block and tabbed or entered the database block. If you add the check of the student id then that should take care of your second requirement. If they enter the database block and the id's don't match then it will execute the query, else they already have the record displayed for them so you don't need to do anything.
    Edited by: MLBrown on Nov 19, 2012 3:08 PM

  • How to query two data blocks simultaneously?

    Dear all,
    Need your inputs on the following problem statement...
    Existing Functionality:
    We have two data blocks A (Parent) and B (Child) in a relationship. Both data blocks refer to different tables.
    Data block A is the query data block and for a single record in block A we can have multiple records in block B. Multiple records in block B are shown one at a time after executing a query, this is implemented by using a list item C (belongs to a third block).
    For example
    Let us say block B can have 5 different types of entries for each record in block A. In this case the list item C will have 5 values corresponding to these entries. Once the query is executed, block B will show the default entry for the queried record in block A. To see other entries for the record user can select the required value in list item C and corresponding entry in block B will be fetched.
    Requirement:
    Our requirement now is to enable querying upon both data blocks A and B simultaneously. To implement this I replaced data blocks A and B with a single data block X which is based on the join of the two tables referred by the Data blocks A and B earlier. As the fields should allow insert, update, delete operations we did not use a view here.
    Issue:
    Now the problem is, each record in block A for which block B had multiple entries earlier is now getting listed multiple times because of the join.
    I have tried but could not find any solution for this. I would appreciate if any of you can suggest how we can query both blocks simultaneously without affecting the existing functionality.
    Thanks,
    Amit

    I don't understand your requirement in detail. I try to repeat what i understood so far.
    You have a master-block A based on a table A and a detail-block B based on a table B. So far so good. You can now query based on conditions just the datablock A, because B is a detail and therefore can only be queryied in context of block A.
    Your reuirement is to query on both blocks A and B and find block in B also without giving conditions for the relevant block A.
    Is it that ?
    What i don't understand, what is block C used for?
    An idea for the querying of block B's data: Create Non-database-items items in block A for the search-criteria you need on block B and make them Queryable.
    In the PRE-QUERY-trigger on block A build a WHERE-condition if that search-criteria is entered, something like
    IF :BLOCK_A.SEARCH_CRITERIA_FOR_BLOCK_B IS NOT NULL THEN
      SET_BLOCK_PROPERTY('BLOCK_A', ONETIME_WHERE, 'WHERE PKVALUE IN (SELECT FKVALUE_TO_A FROM TABLE_B WHERE FIELDVALUE=' ||:BLOCK_A.SEARCH_CRITERIA_FOR_BLOCK_B)');
    END IF;This would query also records to A for which you want to have the B-records. So you could keep block-structure up to master-detail.

  • Sorting the data of control block in oracle form 10g

    I have two block....both are the control block..
    in first block i select the date and in second block the data of that date is populated.but the data is populated
    using cursor in when-button-pressed trigger of that first block button...
    in cursor the data is selected and placed in field of detail block using into clause.... each field..
    .and one item of detail block is srno which is create in post-query of detail block using
    :sysyem.trigger_record.
    Now i want after populated the detail block the data is sorted desc one of the field of the detail block...
    Can this possible using set_block_property() of block although the block is control block if yes where i should do
    this??????
    Please explian...????

    but with the cursor of repopulate ...how the block is in desc by one field..because if i use again the same cursor to poulate than whats this benefits???
    if i write a cursor in button when-button-trigger in first block like this code....
    go_block('');
    cursor emp_cur is
    select empno,date,sal
    from emp;
    begin
    for i in cur loop
    select i.empno,i.date,i.sal
    into :empno,:date,:sal
    from emp
    end loop
    end;
    this loop populate the block which is controll block..
    syntax error should be ignored ...i wana to explain what i want to do...
    this is not the actual query i have another query but the concept is that...
    how i can do this...

  • A good solution to set the actual data record after execute query ..

    Hi,
    in my Form there is a block on a temporary table.
    The user can add query results and wishes to save the last data focus on the last actual record before the execute query to restore this focus after the query.
    Is there a robust and fast solution to save the
    actual data focus - execute_query - restore the saved focus ?
    Thanks
    Friedhold

    Here is a simple solution to try:
    Create a package specification in your form: Package P0 is
      Save_rowid  varchar2(30);
      Found_rec   number;
    End;Create a Key-Entqry trigger on your block: P0.save_rowid := :Myblock.rowid;
    P0.Found_rec := null;
    Enter_Query;Create a Post-Query trigger on the block: If :Myblock.rowid = P0.save_rowid then
      P0.found_rec := :system.trigger_record;
    End if;Create a Key-Exeqry trigger on the block: Execute_Query;
    If P0.found_rec is not null then
      Go_record(P0.found_rec;
    End if;

Maybe you are looking for

  • How to deactivate Adobe Acrobat v7?

    I have Adobe Acrobat Version 7 installed. I would like to move up the Version 9 to use the new features; mass file size reduction and web forms. I want to move the Version 7 installed on my PC by deactivating it -then installed it on some-else's PC a

  • Problem when installing new cpu physics VM 3.0.3

    Hello everyone, we have a server VM 3.0.3 in a Fujitsu RX300 S7, have installed a new processor, and although apparently all is well from the manager can see that it is Server VM fails to boot, and we cannot access to the virtual machines. Anyone kno

  • Compressing movies to free up disk space

    I have 4 movies and they take up 4GB of space. Does anyone know how to make them smaller to free up disk space? The movies that aren't from iTunes are formated for iPod. (I read that somewhere)

  • Results from V$DB_OBJECT_CACHE - the next move?

    Hi. I have run this query onour production db to show which objects we dont have cached in the shared pool. select owner, name, type, sharable_mem, executions from V$DB_OBJECT_CACHE where sharable_mem > 10000 and type in ('PACKAGE', 'PACKAGE BODY', '

  • Purchasing- Set up Employee as Buyer

    I know how to set up an Employee as a Buyer through the application...but can someone tell me how to do this via the backend? I have a conversion to do and want to set up employees as buyers. Is there an API or something?