6 Replies Latest reply: Mar 17, 2013 1:36 PM by HamidHelal RSS

    master detail relationship

    951614
      Hi
      We have 3 blocks based on master detail relationship
      Block A - header block
      Block B - child block (child of block A) - multi block
      Block C - child of block B - multi block

      Block A
      Block C is a display only form that is accessed when button is triggered from the content canvas that Block A and B are present on

      The user will enter data in Block A and B and thenwill save the data at once

      Question
      1) For one record in block B - multiple records could be present in block C.
      We are trying to use a pre-insert statement on Block B and explictly insert records in Block C table. is this approach appropriate.
      2) What are other possible solutions.- - in terms of ttrigers used and at which level.

      Please respond ASAP.

      Regards
      SR
        • 1. Re: master detail relationship
          Amatu Allah Neveen Ebrahim
          Hi Sr
          u either create a relationship between b & c if c is editable then like b it displays the details of A even it is 1or multi records the relation ship type is the definite decision in displaying data relation ship not the shape or type of displaying records.

          consequently the create relation ship between b & c means b is the master each record iinsertedd and saved has many records in c no need to trigger it this is the beauty of oracle form it does insert update & delete with no code required.

          Amatu Allah
          • 2. Re: master detail relationship
            Amatu Allah Neveen Ebrahim
            Hi Sr
            u either create a relationship between b & c if c is editable then like b it displays the details of A even it is 1or multi records the relation ship type is the definite decision in displaying data relation ship not the shape or type of displaying records.

            consequently the create relation ship between b & c means b is the master each record iinsertedd and saved has many records in c no need to trigger it this is the beauty of oracle form it does insert update & delete with no code required.

            Amatu Allah
            • 3. Re: master detail relationship
              951614
              Please let me elaborate the full requirement here....
              once the data is entered in block A and B and saved , based on set of conditions block C should be populated automatically.
              Block is not displayed on the canvas of Block A and B ...but there is a button which causes the block C data to be displayed on a new form - which is a display only form.

              Question
              1) We are using the pre-insert trigger here.
              2) After clicking the button , where we are sending the :BLOCK.item_id_from_block B to called form, we want to fetch the data from table C on which the called form is there....we are fetching the data in a for loop of the when new form intance for display

              Below is the sample code in when new form instance at form leve,

              FOR b IN a
              LOOP
              :Block.item1 := a.item1;
              :Block.item2 := a.item2;
              :Block.item3 := a.item3;
              END LOOP;

              1) is this the correct way of doing it. Should we use a next_record.
              2) What is the appropriate trigger if it is not the above logic ; and at what level.

              Thanks
              Regards
              Siva
              • 4. Re: master detail relationship
                Andreas Weiden
                - i don't know if the PRE-INSERT-trigger is the correct one, as the data in block a and b is not saved at that moment. What happens if the user enters two records in block B? What is shown then in your form C? If there is only one record in B you could use a POST-DATABASE-COMMIT-trigger to call form c.
                - In form C you shouldn't fetch the data with a cursor. Create a database base with an appropiate WHERE-condition and only issue an EXECUTE_QUERY in the WHEN-NEW-FORM-INSTANCE-trigger.
                • 5. Re: master detail relationship
                  951614
                  Hi Andreas,

                  For the first part, yes, there can be more than one record in the block B. What might be the appropriate trigger / level in this scenario.

                  Regards
                  SR
                  • 6. Re: master detail relationship
                    HamidHelal
                    948611 wrote:
                    Hi Andreas,

                    For the first part, yes, there can be more than one record in the block B. What might be the appropriate trigger / level in this scenario.
                    Hi SR
                    If you want to insert record in another table (block C table) after insertion on a table (block B table), you may use POST-INSERT trigger at block level (block B) it will fire after each record insert.

                    Hope this helps

                    Hamid


                    Mark correct/helpful to help others to get right answer(s).*