Solved

trigger

Posted on 2016-07-28
5
49 Views
Last Modified: 2016-07-28
what is the use of trigger in oracle database. where exactly it is used which occassions.
0
Comment
Question by:anishtv
5 Comments
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 41733437
What type of trigger?

There are system level and table level.  There are also "instead of" triggers for DML on views.

The online documentation is the best place to start:
http://docs.oracle.com/database/121/LNPLS/triggers.htm#LNPLS020
0
 
LVL 31

Expert Comment

by:awking00
ID: 41733439
Too many uses to enumerate. It's used wherever the occasion calls for it. Frequently it is used in conjunction with a sequence to generate an identity.
0
 
LVL 73

Accepted Solution

by:
sdstuber earned 500 total points
ID: 41733474
triggers are, in my experience, used when users/applications have direct access to an object  but you want to maintain some level of consistent functionality.

For example - someone writes an insert statement to create a new row in a table.  You can use a trigger to ensure some columns are populated a certain way or others are not populated.  It can be as simple as forcing capitalization, or trimming white space.
or more sophisticated key generation/lookup or complicated calculations.

Similarly, if someone else writes an update or a delete, maybe you want to capture that action and write something else, or possibly block the action if the update or delete is invalid for some reason.


If you have a procedural api instead, that is, nobody can write sql directly against the object, but can only access it through procedures, then triggers are not necessary and are generally considered bad practice.
0
 
LVL 15

Expert Comment

by:Devinder Singh Virdi
ID: 41733488
Another important thing about trigger is that it slows down DML because for every DML Oracle has to invoke and execute Trigger code.
0
 

Author Closing Comment

by:anishtv
ID: 41733949
Thanks
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now