Re: Master - Detail Blocks , Query ???

From: DanHW <danhw_at_aol.com>
Date: 4 Dec 1998 05:24:35 GMT
Message-ID: <19981204002435.12646.00002070_at_ng-cc1.aol.com>


>Hello,
>
>I hava a master-detail relation between two blocks in my Forms 4.5 form.
>
>The user wants to query based on some criteria from both master and detail
>blocks. Is it possible ?
>
>The next question is, if the user enters only criteria for the detail
>block, is there any way, we can get the master record, pertaining to
>the detail records fetched ? (I tried querying the detail and it fetches
>only the detail records without the master record)
>
>Any help appreciated.
>Thanks in advance.
>Prasad.
>

What I have done is similar to Andrew's suggestion, but with a little twist. Unfortunately I don't have the code in front of me, but perhaps this will help you.

  1. Define a queryable field on the main block.
  2. In the when-new-record trigger, set the field to be displayed/enterable only if you are in query mode (SYSTEM.MODE, I think). If you are not in that mode, hide the field.
  3. In the pre-query trigger, if the user entered a value in that field, modify the query to do something like this (You will need to make the PK in the master table have a very long query length)

if :master_block.detail_condition is not null then

       master_block.pk := '# in (select pk from detail_table where value='||master_block.detail_condition)'; end if;

You will have to experiment with the syntax to get it correct, but that is the basic idea.

Dan Hekimian-Williams Received on Fri Dec 04 1998 - 06:24:35 CET

Original text of this message