|
Re: Before insert and after insert trigger [message #373699 is a reply to message #373694] |
Wed, 02 May 2001 06:48 |
Ramanarsaiah Katam
Messages: 4 Registered: May 2001
|
Junior Member |
|
|
Before insert trigger fires when you are about to insert a record in the table and after insert trigger fires after the record is inserted.
for example if you want to prevent the user to insert records on holidays,you use a before insert trigger which checks the holidays before inserting and if the day falls in holiday it will not allow to insert.
for after insert, for example,if you want to monitor the users who created new records and when, you can use after insert trigger which fires after inserting the record and in that trigger you can trap the user and time.
Ram
|
|
|
Re: Before insert and after insert trigger [message #373700 is a reply to message #373699] |
Wed, 02 May 2001 07:01 |
sunil gupta
Messages: 11 Registered: September 2000
|
Junior Member |
|
|
Hi Ram,
thanks for the reply. I was wondering that I can also trap the user and time who inserted the record in a before insert trigger. So is it we use after insert trigger so as to make sure that record is inserted and there is no network failure. Or if there is any other reasin pls let me know.
Thanx
Sunny
|
|
|
Re: Before insert and after insert trigger [message #373704 is a reply to message #373699] |
Wed, 02 May 2001 07:45 |
Ramanarsaiah Katam
Messages: 4 Registered: May 2001
|
Junior Member |
|
|
I have given only example that we can trap a user in after insert trigger, but as you said you can trap user in before insert also.Another example is if you want to insert an employee record in emp table for deptno 80.But there is no deptno 80 in dept(master) table.so it wont take the record.so here you will use before insert trigger on emp table, in which you check whether the deptno existing in the master table, if not insert the dept record in deptno and then the record will be inserted into emp.
Ram
|
|
|