0% found this document useful (0 votes)
47 views

What Is A Trigger?

A trigger is procedural code that is automatically executed in response to certain events on a database table. There are two types of triggers - row triggers that execute for each row affected, and statement triggers that execute once regardless of row count. Triggers can fire before or after events like inserts, updates or deletes, and are commonly used to perform logging, auditing or other actions in response to data changes. Well-designed triggers improve data quality and security.

Uploaded by

satish_msc_dwh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views

What Is A Trigger?

A trigger is procedural code that is automatically executed in response to certain events on a database table. There are two types of triggers - row triggers that execute for each row affected, and statement triggers that execute once regardless of row count. Triggers can fire before or after events like inserts, updates or deletes, and are commonly used to perform logging, auditing or other actions in response to data changes. Well-designed triggers improve data quality and security.

Uploaded by

satish_msc_dwh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

A stored procedure is a set of SQL commands that has been compiled and stored on the

database server.

Once the stored procedure has been "stored", client applications can execute the stored
procedure over and over again without sending it to the database server again and without
compiling it again.

Stored procedures improve performance by reducing network traffic and CPU load.

What is a Trigger?

A database trigger is procedural code that is automatically executed in response to certain events
on a particular table in a database. Triggers can restrict access to specific data, perform logging,
or audit access to data.

There are two classes of triggers, they are either "row triggers" or "statement triggers". With row
triggers you can define an action for every row of a table, while statement triggers only occur
once and are not dependent on the shape of the data.

Each class can be of several types. There are "BEFORE triggers" and "AFTER triggers" which
alters the time of execution of the trigger. There is also an "INSTEAD OF trigger" which is a
conditional trigger that will fire instead of the triggering statement.

There are typically three triggering EVENTS that cause trigger to 'fire':

• INSERT event (as a new record is being inserted into the database).
• UPDATE event (as a record is being changed).
• DELETE event (as a record is being deleted).

Databases that support triggers typically give programmers access to record variables by means
of a syntax such as :OLD.cust_name or :NEW.cust_name. e.g. if a trigger is monitoring for
changes to a salary field one could write a trigger.

BEFORE UPDATE ON employee_table


FOR ALL records
IF :NEW.salary <> :OLD.salary THEN
do something here
END IF;
END;

Oracle 9i allows you to create triggers on schemas and databases also.You can create a trigger
for creating or altering or dropping a schema object.Triggers can also be created for logging in
and logging out of databases.
Schema Level Triggers

• Before Create
• After Create
• Before Alter
• After Alter
• Before Drop
• After Drop
• After Logon
• Before Logoff

The major features and effects of database triggers are that they:

• do not accept parameters or arguments


• can commit/rollback only through autonomous transactions
• can cause mutating table errors, if they are poorly written.

http://www.scribd.com/full/35917?access_key=hecr63dsuf95v

u can check out very gud q@ans here vvgud..

You might also like