[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 302
  • Last Modified:

TRIGGER - Not updating past first statement

Hi, I have a trigger below that has 4 other table update statements in it.

When executing the trigger only the first shows that it executed.

Are you not allowed more than one update in a trigger. What can be done to have all 4 fire successfully or if any one fails to rollback all? (thought that was normal trigger execution)

Thanks..
create or replace TRIGGER "MY_BU"
    BEFORE UPDATE
    ON MY
    FOR EACH ROW
 declare   
    ln_POP_MY_ID number;
BEGIN   
    if(:new.FRR_ID =2)then    
       
        --MY_GEN_XREF_V (BD_SRC_SEC)
            UPDATE BD_SRC_SEC
               SET FRR_ID=2
             WHERE (SRC_ID = :new.MY_ID   -- MY_ID (SRC_ID)
                       OR VALUE_ID = :new.MY_ID ) -- GEN_ID (VALUE_ID) assigned to MY_ID (SRC_ID)
               AND SRC_TYPE_ID = 7
               AND SEC_ATTR_ID = 2
               AND FRR_ID =1;        
    
        --BD_POP_FRR_XREF
           UPDATE BD_POP_FRR_XREF
              SET FRR_ID =2
            WHERE MY_ID = :new.MY_ID
              AND FRR_ID =1;

        --MY_PROGRAM_XREF_V (BD_SRC_SEC)
            UPDATE BD_SRC_SEC
               SET FRR_ID=2
             WHERE SRC_ID = :new.MY_ID   -- MY_ID (SRC_ID)
               AND SRC_TYPE_ID = 7
               AND SEC_ATTR_ID = 5
               AND FRR_ID =1;

        --BD_PROGR_SUPPL_XREF
            UPDATE BD_TRACE_XREF
               SET FRR_ID=2
             WHERE PUBL_ID =:new.MY_ID
               AND FRR_ID =1;
   end if;
  :new.last_updated_by := NVL(v('APP_USER'), USER);
  :new.last_updated_on := SYSDATE;
END;

Open in new window

0
bcarlis
Asked:
bcarlis
2 Solutions
 
AkenathonCommented:
You are allowed as much SQL and PL/SQL as you want in a trigger. What's your evidence to claim that only the first update is executed? Maybe your WHERE predicates don't match anything, so no rows are updated in the other ones.

Check SQL%ROWCOUNT after each one and/or enclose them into blocks with EXCEPTION handlers. However, if any of them raises an error it will be propagated to the SQL that fired the trigger in the first place -you don't have to do anything if you want just that.
0
 
Aaron ShiloCommented:
hi

move al your logic into a procedure and use the trigger to cal the procedure
that will make thinks manageneble and easy and Working :-)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now