SQL Unit5
SQL Unit5
SQL Programming
Module: 5
Learning Objectives:
exceptions in PL/SQL.
resistant code.
triggers.
Structure:
5.7 Summary
5.8 Keywords
5.11 Reference
database.
1. Error Detection:
● Exceptions enable the identification of errors and
testing phases.
2. Segmentation of Logic:
3. Recovery Mechanisms:
one row).
encounter include:
There may arise scenarios where the built-in exceptions are not
experiences.
Approach
1. Declaration:
MY_EXCEPTION EXCEPTION;
RAISE statement.
● Data corruption
● Resource unavailability
● System malfunctions
failures.
programmatic flow.
handle deviations:
Example:
DECLARE
my_exception EXCEPTION;
BEGIN
IF some_condition THEN
RAISE my_exception;
END IF;
EXCEPTION
END;
● RAISE_APPLICATION_ERROR: A powerful built-in
Example:
BEGIN
IF some_condition THEN
to some_condition');
END IF;
END;
an issue.
● Provide meaningful feedback: Whether logging the error
responses to exceptions.
Triggers are specialised routines that are set into motion (or
changes occur.
● Components:
differences:
● Activation:
by a user or application.
● Purpose:
● Control:
versatile use.
operations:
invoice automatically.
DELETE.
acts:
table.
which level.
3. Write the PL/SQL Code: Define the logic inside the trigger
body.
BEGIN
END;
● Modifying Triggers:
● Disabling Triggers:
● Dropping Triggers:
trigger_name; command.
it.
performance:
unintended results.
database operations.
1. Trigger Types:
row.
Triggers:
● Row-level:
field.
triggering statement.
● Statement-level:
operations.
● BEFORE:
completing.
or notifications.
● Functionality:
● Row-level:
● Statement-level:
row-specific details.
● BEFORE:
o Data validation.
o Data transformation before persistence.
● AFTER:
● INSTEAD OF:
5.7 Summary
termination.
predefined ones.
execution paths.
rules.
database events.
5.8 Keywords
application logic.
business logic.
operation.
handling?
invoked once for each row that meets the triggering event
criteria?
Introduction:
Challenge:
Solution:
Outcome:
Questions:
analysis?
5.11 References
Bill Pribyl
Kallman
Spendolini
McLaughlin