How is a trigger compiled?

Are you preparing for IT certification? With practice questions, study notes, interactive quizzes, tips and technical articles, uCertify PrepKits ensure that you get a solid grasp of core technical concepts to ace your certification exam in first attempt.

How is a trigger compiled?

Rating:

A trigger is similar to a PL/SQL anonymous block, but with the additional :NEW and :OLD capabilities. However, their compilation is different. A PL/SQL anonymous block is compiled each time it is loaded into the memory. The compilation involves the following three stages:

  • Syntax checking: PL/SQL syntax is checked and a parse tree is generated.

  • Semantic checking: Type checking and further processing on the parse tree are performed.

  • Code generation: The pcode is generated.


  • A trigger, in contrast, is fully compiled when the CREATE TRIGGER statement is executed. The pcode is stored in the data dictionary. Hence, firing the trigger no longer requires the opening of a shared cursor to run the trigger action. Instead, the trigger is executed directly.

    If errors occur during the compilation of a trigger, the trigger is still created. However, if a Data Manipulation Language (DML) statement fires this trigger, the DML statement fails. The SHOW ERRORS statement can be used within SQL*Plus or Enterprise Manager to see the compilation errors that occur during the creation of a trigger. The USER_ERRORS data dictionary view can also be queried to see the compilation errors.


    Rating:



    Other articles

    Click here to Article home

    MCSE: MCSA, MCTS, MCITP    JAVA Certification: SCJP, SCWCD Cisco Certification: CCNA, CCENT, A+, Network+, Security+

    Oracle Certification: OCP 9i, OCP 10g, OCA 9i, OCA 10g, 1Z0-040: Upgrade to OCA 10g Fundamentals I, Oracle Fundamentals II, Admin I, Oracle Admin II, PL/SQL CIW foundation    Photoshop ACE
    © 2008 uCertify.com. All rights reserved. All trademarks are the property of their respective owners.
     
    HACKER SAFE certified sites prevent over 99.9% of hacker crime.