Trigger - Data from Multiple table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Reshmi Jacob
    New Member
    • Sep 2006
    • 50

    Trigger - Data from Multiple table

    Hi all

    I have a table ,say SUMMARY. I need to write a trigger in such a way that in another table ,say TRN, when an INSERT occurs I need to insert some data from fields of TRN and its child table TRNCHILD should go to summary.

    If it was only from one table , I can write ...

    CREATE OR REPLACE TRIGGER TRG_TRN
    AFTER INSERT ON TRN
    FOR EACH ROW

    BEGIN
    If INSERTING Then
    INSERT INTO SUMMARY(a,b,c) VALUES(:NEW.Val A,:NEW.ValB,:NE W.ValC);
    END IF;
    END

    My Question is if ValC is from TRNCHILD, which has a link with TRN, how can I get this data????

    Regards
    Reshmi
  • suvam
    New Member
    • Nov 2006
    • 31

    #2
    in that case u have to etch that value through that link from TRNCHILD table into a local variable and then use that variable in place of :NEW.Valc .

    Comment

    • pragatiswain
      Recognized Expert New Member
      • Nov 2006
      • 96

      #3
      Originally posted by suvam
      in that case u have to etch that value through that link from TRNCHILD table into a local variable and then use that variable in place of :NEW.Valc .
      If child table data is committed or inserting in the childtable happens in the same transaction, then there is no problem. Do as Suvam has suggested you.

      But if insertion in Child table happens in another session and not commited, you can not see the data. So, you have to design the application accordingly.

      Comment

      Working...