Procedural constraint enforcement (triggers) , PL-SQL Programming

Procedural Constraint Enforcement (Triggers)

SQL has an alternative method of addressing database integrity, involving event-driven procedural code. The special procedures that can be used for this purpose are called triggers and the events that activate them are specified update operations. For example, suppose it is required for every row in IS_CALLED to have a matching row on StudentId in IS_ENROLLED_ON, enforcing a business rule to the effect that every registered student must be enrolled on at least one course. Then a triggered procedure might be activated every time INSERT is used to add a row to IS_CALLED, checking to see if a matching row exists in IS_ENROLLED_ON and raising an exception if there isn't one. But that wouldn't be sufficient to address the requirement.

Further triggers would be needed, activated by UPDATE statements on IS_CALLED and IS_ENROLLED_ON that cause changes to StudentId values in either of those tables, and by DELETE statements on IS_ENROLLED_ON. As this simple example demonstrates, use of triggered procedures for constraint enforcement can be complicated and error-prone. As one practitioner told me, "It quickly gets so complicated that it's almost impossible for a human not to make errors..., and even when you're not facing a 'complicated' case, the work to be done is tedious and boring".

Posted Date: 1/18/2013 7:25:02 AM | Location : United States







Related Discussions:- Procedural constraint enforcement (triggers) , Assignment Help, Ask Question on Procedural constraint enforcement (triggers) , Get Answer, Expert's Help, Procedural constraint enforcement (triggers) Discussions

Write discussion on Procedural constraint enforcement (triggers)
Your posts are moderated
Related Questions
Avoiding Collection Exceptions   In many cases, if you reference a nonexistent collection element, then PL/SQL raises a predefined exception. Consider the illustration shown b

Brewbean's is implementing a new discount for return shoppers - every fifth completed order receives a 10% discount. The count of orders for a shopper is placed in a packaged varia

Using the Collection Methods The collection methods below help to generalize the code and make collections easier to use and also make your applications easier to maintain:

Example of Shorthand for a row constraint Example: Shorthand for a row constraint ALTER TABLE EXAM_MARK ADD CONSTRAINT Mark_in_range CHECK (Mark BETWEEN 0 AND 100);

Keyword and Parameter Description select_statement: This is a query which returns a result set of the rows. Its syntax is such that of select_ into_statement without the IN

Defining and Declaring Collections To create the collections, you must define a collection type, and then declare the collections of that type. You can define the VARRAY types a

Product-specific Packages The Oracle and different Oracle tools are supplied with the product-specific packages which help you to build the PL/SQL-based applications. For illus

BETWEEN and NOT BETWEEN Operator in SQL Example: Restricting exam marks to between 0 and 100 CREATE ASSERTION Marks_between_0_and_100 CHECK (NOT EXISTS (SELECT * FROM

Using the FORALL Statement The keyword FORALL instruct the PL/SQL engine to bulk-bind input collections before sending them all to the SQL engine. Though the FORALL statement

PRIMARY KEY: PRIMARY KEY  indicates that the table is subject to a key constraint, in this case declaring that no two rows in the table assigned to ENROLMENT can ever have the