Solved

trigger

Posted on 2016-07-28
5
69 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

739 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