Searching master block based on value in detail block

I have two blocks on a form. A master block for purchase orders and a detail block for the line items. I need to provide users with the ability to search the purchase orders based on the values entered into the detail block (line items), during the query entry. I am considering to check to see which block the cursor resides by using the :SYSTEM.CURSOR_BLOCK variable, then retrieving the value from the current item and running a query, using that query. The problem is that I am not very familiar with Forms and do not know how to implement my idea. Any ideas?
null

I copied you an example from metalink. Hope it will help.
Doc ID:
Note:109583.1
Subject:
How to query a Master record from a Detail Block
Type:
BULLETIN
Status:
REVIEWED
Content Type:
TEXT/PLAIN
Creation Date:
22-MAY-2000
Last Revision Date:
03-AUG-2001
PURPOSE
------- To query a master record from a detail record. DESCRIPTION
=========== The user would like to enter a query criteria in the detail block
and then query the master record based on the above user input. SOLUTION
======== Create the master and detail blocks and the relationship in the usual
manner. We will consider here the blocks DEPT and EMP based on the
SCOTT schema. 1. Create a KEY-ENTQRY trigger at the block level of the detail block
(EMP) and add the following code in it : GO_BLOCK('dept');
CLEAR_BLOCK(no_commit);
GO_BLOCK('emp');
ENTER_QUERY; 2. Create a KEY-EXEQRY trigger for the detail block and add
this : EXECUTE_QUERY;
:global.deptno := :emp.deptno;
:global.flag := 'T';
GO_BLOCK('dept'); This will store the value of the deptno (primary key) in a global variable
:global.deptno and set another global variable :global.flag to 'T'. This
will be explained as we progress. 3. Create a WHEN-NEW-RECORD-INSTANCE trigger for the detail block
and add the following : -- This is used to populate the MASTER block with the corresponding
-- record whenever the user navigates through all the records in the
-- DETAIL block if get_record_property(:system.cursor_record,:system.cursor_block,status) = 'QUERY' then
SELECT rowid,deptno,dname,loc
INTO :dept.rowid,:dept.deptno,:dept.dname,:dept.loc
FROM dept
WHERE deptno = :emp.deptno; -- This is to set the status of the record populated
-- to QUERY and not to create a new record SET_RECORD_PROPERTY(1,'dept',status,QUERY_STATUS);
end if; 4. Create a WHEN-NEW-BLOCK-INSTANCE trigger for the master block again
and add this : if :global.flag = 'T' then -- set the variable to a different value
:global.flag := 'F';
:dept.deptno := :global.deptno; -- This will query the master table for the record based on the
-- deptno of the detail table which is stored in :global.deptno -- For ex: if an employee of department 10 has been queried in
-- the detail, then the global.deptno will have the value 10,
-- which is used in the query below to fetch the master record. SELECT rowid,deptno,dname,loc
INTO :dept.rowid,:dept.deptno,:dept.dname,:dept.loc
FROM dept
WHERE deptno = :global.deptno;
set_record_property(:system.cursor_record,'dept',status,QUERY_STATUS);
GO_BLOCK('emp'); end if; EXPLANATION
=========== Actually in the above method we are using the base table blocks as a
non-base table block when we query the master from detail. We are
displaying the master record fetched from the table based on
the query supplied in the detail. So after the fetch, if we clear the
block or form then we get a "Do you want to save the changes you have made"
alert. So in order to supress this while entering a normal master-detail
query, we have created the global variable, :global.flag. There is a limitation though, if you query detail records and then
navigate to the master block and then press the down arrow( i.e.,
navigate to the next record) and then presses the up arrow to
navigate back to the same record, then the detail records that
were originally populated will change and a new set of records will
get displayed. This is because the normal master-detail query is
taking place during MASTER record navigation. This can be controlled by creating a flag (global variable) and setting
its value and thus preventing the user from navigating to the next master
record. Do the following : 1) In the KEY-EXEQRY trigger of the detail add the following :global.control_master := 1; 2) Create a KEY-EXEQRY for the master and add this : :global.control_master := 0;
EXECUTE_QUERY; 3) Create a KEY-DOWN in the master with the following in it: IF :global.control_master <> 1 THEN
down;
END IF; Declare all the global variables before running the Form. RELATED DOCUMENTS
Note:611.1

Similar Messages

  • How to query the master block based on one of the values in detail block

    Hi,
    In version 6i forms, I have a field in data block which is not set as a database item. I am using that field to store a value from detail block. If I want to query the form using that field (which represents one of the values from detail block), how do I do that? Any pointers?
    TIA,

    Do you want to query a master, which contains a specific detail? If so, here's an example how you could do it with a PRE-QUERY-trigger:
    DECLARE
      vcQuery VARCHAR2(4000);
    BEGIN
      IF :MASTERBLOCK.THE_DETAIL_SEARCH_ITEM IS NOT NULL THEN
        -- Build up an exists Sub-Query
        vcQuery:=' MASTERBLOCKID IN (SELECT FK_TO_MASTERBLOCK FROM DETAILTABLE WHERE DETAIL_COLUMN=''' || :MASTERBLOCK.THE_DETAIL_SEARCH_ITEM|| ''')';
      END IF;
      SET_BLOCK_PROPERTY('MASTERBLOCK', DEFAULT_WHERE, vcQuery);
    END;

  • Compare values in detail block

    Hi everyone,
    I have a detailed block which has many records. What's the best way to loop though the detail records and compare the values in the same field in the next, previous record or all detail records.
    Thanks for your help.

    For example, in field A you can only add a record where the value in field A is
    ABC. for this master record.Ok, it sounds like you want a field (field A) to be the link between the master and detail records, which is a common situation. Forms will handle this for you if you use a relationship between the master and detail blocks - the value of the link field in the master will be put into the detail block automatically.
    I would like to look at record 3 value in field A (CBA) and compare it to record 1 and 2.Now I'm confused. Do you have a master record or will you simply be setting field A to the same value for every record? If so then why display the field on each row? You could have a single field at the top of the form and populate each row before inserting it. Is it possible to have a mix of values in field A after querying the records? If so then how do you decide what value should be used for new records?

  • Query a database block based on a non-database block

    hi everybody
    can anybody help me as how to query a database block based on a non-database block, without a master-detail relationship?
    i have a block : date_input which contains a non-database item: start_date
    another database block (event_block)containing details of an event
    i have to input a date in the start_date and query the event_block
    in wich trigger should i insert the code?
    thanks

    If you are trying to query your database block (event_block) using the value from start_date in your non-database block, then you can set the Where clause in the database block using:
    SET_BLOCK_PROPERTY ('event_block', DEFAULT_WHERE, 'your where clause that includes start_date');
    Place this statement in a trigger that is executed prior to the block being queried.

  • Unable to see the values in detail block

    Hello,
    I have a master detail block, when I query the form, I am unable to see the values for a particular field(Column), all other columns appear properly in the details block, Upon checking the same table(s) in SQL ( by using the JOIN defined in the where clause of the relationship in Forms) , it shows the relevant records for all fields. So what could be wrong with the Form, please advise.
    Thanks
    FM

    IQ wrote:
    I have just checked the field its a non-database field which is being used as a LOV column to display a value derived from LOV. How do I make this populate at Query time, as obviously this works when the Form is in a insert mode but not for Query mode. How to make it work for Query ? As it for LOV column and non-database filed, ignore my first suggestion.
    Does your non-database filed has associate any column ?
    For example, you have SUPPLIER_ID (database column) and SUPPLIER_NAME (non-database column). SUPPLIER_NAME has LOV column. And when selecting supplier name from LOV value also assign at supplier_id.
    Now to show supplier name when querying, you have to write POST-CHANGE trigger at supplier_id. like
    SELECT ASSC_CODE INTO :MST_SUPPLIER.ACC_CODE
    FROM ACC_SUB_SUB_CONTROL
    WHERE ASSC_ID=:MST_SUPPLIER.SUPP_ASSC_ID;Hope this helps

  • Filter master rows based on attributes in detail view.

    Hi,
    How do I set up VO's so that I can:
    1. filter master records based on attribute values in either the detail or master attribute values.
    and
    2. display each distinct master record with all its associated detail records.
    Stated another way, I want to list all the master records (with their associated detail records) filtered by the existence of qualifying detail records -- give me all departments which have assigned one or more employees who meet some criteria; list the departments and ALL the dept.'s employees (regardless of whether they individually meet the criteria).
    We've been struggling with this for a couple of weeks. I've been trying to accomplish this on 10.1.2, 9.0.5.2 and 9.0.3.3 with pretty much the same results on all three versions.
    To make queries based on values in either the master or detail records we created a database view that denormalizes the tables. This let's us include criteria based on either the master or detail tables, but of course rows from the master table may appear multiple times. We tried a DBMS global temporary table, but the inserted rows were not visible to the client; I'm assuming they're discarded with the session between queries or the queries establish separate sessions. I tried marking only the master record columns as selected and queriable and the detail columns as just queriable, but this causes the detail columns to be defined as transient VO attributes.
    TIA, for ideas or guidance.

    Hi,
    How do I set up VO's so that I can:
    1. filter master records based on attribute values in either the detail or master attribute values.
    and
    2. display each distinct master record with all its associated detail records.
    Stated another way, I want to list all the master records (with their associated detail records) filtered by the existence of qualifying detail records -- give me all departments which have assigned one or more employees who meet some criteria; list the departments and ALL the dept.'s employees (regardless of whether they individually meet the criteria).
    We've been struggling with this for a couple of weeks. I've been trying to accomplish this on 10.1.2, 9.0.5.2 and 9.0.3.3 with pretty much the same results on all three versions.
    To make queries based on values in either the master or detail records we created a database view that denormalizes the tables. This let's us include criteria based on either the master or detail tables, but of course rows from the master table may appear multiple times. We tried a DBMS global temporary table, but the inserted rows were not visible to the client; I'm assuming they're discarded with the session between queries or the queries establish separate sessions. I tried marking only the master record columns as selected and queriable and the detail columns as just queriable, but this causes the detail columns to be defined as transient VO attributes.
    TIA, for ideas or guidance.

  • Populating called block based on criteria from previous block

    i have a form where the query is based on the zipcode provided. I have a button within block a that calls another block b to display all records with that particular zipcode. I want the display on block b to show only the records for the specified zipcode. Please help and tell me how do I make this happen?

    - In the WHERE-Clause-property of block b enter :
    :BLOCK_A.ZIP_CODE
    - Put a button next to Zip-Code of Block a
    in the WHEN-BUTTON-PRESSED trigger enter :
    GO_BLOCK('BLOCK B');
    EXECUTE_QUERY;
    Another option would be to use a relation between both blocks ...

  • Recommended best practice to fetch detail block based on procedure

    HI
    I am creating a detail block (Dept)based on procedure which will be populated from the value from master block 'Emp'.
    For example,
    Detail block 'Dept' will be populated by calling procedure populate_detail(:emp.empno in number,dept.deptno out number) .
    But what are the triggers I need to call to populate detail block and at which level?
    I was thinking to call a WHEN-MOUSE-DOUBLECLICK on master block 'Emp' level to populate the detail block 'Dept' by calling the procedure and passing emp.empno as the parameter whenever the user moves from one master record to another.
    Please advise.
    Thanks in advance.

    Download the forms 6i examples CD from the OTN website

  • Two Master  and two details block problem

    Hi,
    I am getting problem in displaying the correct records on one of the detail block. There is one main master block 'A' and then it has one details block 'B' and then this detial block 'B' has got two details blocks 'c' and 'D'. I form different queries based on the value selected at detail block 'D'. Now i go to ,aster block and execute_query then it fetche the correct record at master block not on detail block 'D'. I have one anmoly in Dtails Block D and Master block B that they are joined with a common field not on the basis of proimary key and forign key. Please sugget

    Hi,
    When you establish the relations using the references, then oracle will look for the parent key in both the parent tables. Either you need to remove the foreign keys or change your db design to add one more table and have one-one parent child relationships.
    HTH
    Regards,
    Badri.

  • Change in master block record not cascading to detail record blocks

    Using Forms [32 Bit] Version 10.1.2.2.0 (Production)
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
    I am encountering the following problem in my form:
    I have a master block that has 2 associated detail blocks, one of which acts as a master block for another detail block:
    Master ---- Detail
             \__ Detail(master) ---- DetailThe first two detail blocks are joined to the master block on 3 fields, a date, a 10 digit code and a 5 digit code.
    The third detail block is joined to its master block by 4 fields, 2 dates, the 10 digit code and the 5 digit code.
    The problem I am encountering is when any of the fields that the blocks are joined on are updated in the master block (they don't show up in the form for the other blocks, it auto populates them) the detail blocks are not also updating and the records are being orphaned.
    So if my master block has the following data:
    January 1, 2009
    1234567890
    abcde
    And there are detail records matching this, but the master block changes too:
    January 1, 2009
    1234567890
    edcba
    Rather then the detail records being updated with this new 5 digit code, it shows up blank on the database as it cannot find detail records that match that new set of data. The records still exist in the table, but they are not updated when the master block is updated. Do i need to change the relation properties of the blocks?

    It is not a good practice to update the primary key values especially when those fields act as foreign keys.
    So it will be better to make those fields UPDATE_ALLOWED false.
    If that is an unavoidable condition, in the pre-update trigger of header block, write the update script to update those fields and re-query the detail
    Or
    in key-commit
    loop thru all the records in detail blk and assign values to those feilds and save it

  • Multiple master blocks populating the same detail blocks

    Hey guys. Im doing something a little weirder than I usually do but I can't get it to work correctly and im wondering if any of you have accomplished this before.
    I have a call center application which processes applications by either the application or by follow up. The application and follow up are each a block by themselves located on a separate pages on a tab canvas. Both these blocks are master blocks to the detail blocks which would be user_phones, user_addresses, user_bank_accounts, etc. The idea is I can use either page of the tabs and flip through either the follow up, or application master block and have it populate the user tables according to the user_id found on the master blocks. I figured I could use a when-new-block-instance trigger to switch off which block fires the on-populate-details trigger.
    The problem is.... complicated. If I go to the follow up block and execute query, it brings back the right information on the detail block. The strange thing is it seems like when I move the cursor to a different record on the same block, forms is almost setting a SET_BLOCK_PROPERTY DEFAULT_WHERE action. This is un-noticeable until i go to the other master detail block. When I start using the applications block, it seems like all the detail records actually MATCH the user_id that the cursor was on in the follow up block...
    phew! thats a lot of description for such a strange problem..
    Anyways. Anyone encountered this before? Has anyone ever built a two master block form to populate the same detail block? Is it possible? I haven't found a thread in the forum about this subject..
    Any help would be great. Thanks in advance :)

    Having one detail block for two master blocks was never a use case that we considered for Forms. It sounds like you are trying to make a many-to-many relationship work with two master blocks. I suggest you think about having an intermediate block (hidden or not) that drives the detail block and make each master block drive that intermediate block instead of driving the detail block directly.

  • How to prevent duplicate entry in Details block

    Dear All
    I am using Forms 10g.
    I have a detail block.
    There is a column called Ip_Address.
    There i want to prevent duplicate entry .
    How can i do this ?

    hey i have a requirement that to restrict duplicate entry in both block(both multi record).the blocks are DEPT(MATER)
    EMP(DETAIL)
    the associated fieds in master block DEPT.DEPT_NO,in detail EMP.EMP_ID .
    I have done' Kevin D Clarke’s calculated item ' both in master and detail block
    its working fine for master block but in case of detail block its only respond to the current session(i.e. if the new value is inserted or save it will restrict another record to be inserted of that last record's value),it does not restrict duplicate value enter ,checking with other existing records(which are saved in earlier session,though after query it is shown on the form)
    can anyone guide me why its not working

  • How to fetch the data based on header in detail.

    Hi,
    Below is my requirement:
    I need to create a two non-database control blocks(header and detail) with multirecord.
    When i press the one button i need to fetch the data header block.
    If i select the any record i need to get the detail record values in detail block.
    Please suggest in which trigger i need to write the code. Please explain clearly.
    Regards,
    M. Satish

    hello
    I agree with Mr. Andreas Weiden . use the standard function for the blocks.
    First if you have any PK or FK relationship with the two tables then you can use the table wizard then just follow the procedure and be sure you click the checkbox which is default, automatically create relationship.
    If you dont have PK/FK then just follow again the table block wizard ... just unclick the check box for autocreate relationship then press button to create base on the SQL join.
    on the create join editor :
    deptno = empdepno
    the press okey. forms wizards will create all the rest... you can now notice a new object RELATIONSHIP below the DEPARMENT BLOCK and some forms genareted triggers.
    And CHANGE THE BLOCK PROPERTIES TO UPDATE ABLE,INSERT ABLE, DELETE to NO.. IF YOU WANT ONLY ON DISPLAY
    OR BETTER CREATE A 2 VIEWS CORRESPONDENT TO YOUR QUERY ON YOUR CURSOR.... and follow the procedure i gave above.
    In your button:
    go_block(your.block);execute_query(no_validate);

  • How to display total in a block without total showing up in relevant detail block

    Hi there,
              I create a worksheet, including two block, one of which have detail information with multiple characts and one key figure, another block only have sumerization information takes one cell, which is summarized key figure for that detail information block.
             I implement this summary cell with formula 'GETDATA', but it is only effective after I show total for detail block.
            such as for detail block:
                         employee_no,  wage type,  earning_amount.
                         overall result                        total for earning_amount
            for summary block:
                         summary of earning_amount for all employees in the detail block.
    please tell me how to display summary block without pulling in overall result for detail block.
    Many Thanks,

    Hi bo zhang,
    This can be a work around
    As Michael Tocik suggested
    goto components tab, right click on data source and select copy
    do not insert cross tab
    then use the formula for DS_2 like
    =SAPGetData("DS_2","earning_amount","employee_no=TOTAL")
    this should work.
    and if you do any drill down for DS_1, the above total will not chnage because that is dependent on DS_2
    Hope it helps
    Best Regards,
    Subhash

  • Query based on a non-database item in master/detail block

    Hi,
    I have a master/detail block, and in the master the block in have non database control item which displays the user name. Now i would want to retrive all the master/detail records based on the control item. Is that possible? How can i do it?
    Any help would be appriciated.
    Thanks
    Kavitha

    use the set_block_property (default_where) and the execute_query built-ins. more info in the online help

Maybe you are looking for

  • Problem loading images in adobe bridge html photo gallery

    Can someone please, please help me!? I can not figure out why the images will not load in my adobe bridge html photo gallery cs5. I am not getting any error messages in Firefox and just the x in internet explorer. Here is the link to the gallery page

  • SELECT with WHERE clause for MSAccess from JDBC

    Hi, I am new user of MSAccess.I am getting exception: Invalid user type when i was trying the following code: String name1=nameTextfield.getText().trim(); String query="SELECT ID from Suppliers WHERE name=name1;" Statement stmt=con.createStatement();

  • Imported PNG pics from PS problem. .

    Hi to all members here! I am new to this forum, and if I posted here wrongly I am sorry. You can delete or move this if this post already exists or in the wrong thread.. I am new to flash CS5 and I am having a problem creating a character with multip

  • CS Premium Activation Code Needed

    I have Adobe CS Premium. 14 Months ago I tried to web activate it on my new computer and I could not. I contacted Adobe and you gave me an activation code over the phone. Everything worked fine on my Win Prem 7 Op System. In fact it worked better tha

  • SUBMIT - donot know parameter name

    Hi Gurus, I am calling a report from another report. Inside report_2 i am using, SUBMIT report_1 AND RETURN. I am getting one more screen,with one parameter which can be filled dynamically. I want to hard code this in my code itself just to make sure