Solved

trigger

Posted on 2016-07-28
5
67 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 77

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 32

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 74

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.

713 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