Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Before and After trigger - when to use

Status
Not open for further replies.

Christi

Programmer
Dec 28, 2001
14
0
0
US
I know this question is dumb but please forgive me. Like I said in an earlier thread, I am a newbie on forms, reports.
My question when do I use before insert, update, delete and after insert, update, delete?
I have some fields that need to perform certain actions after insert/update/delete but when I right-click on the item on a block and click pl/sql editor, I don't see before insert/update/delete. I don't even see pre-insert or pre-update or pre-delete.
Similarly, I need to understand when to go to block level trigger.
This is frustrating me, please help!
thank you
 
You should distinguish Forms/Reports triggers from database triggers. Forms triggers are event handlers of form objects. But the range of events for those objects is not limited by insert/update/delete.

You may use block-level triger if the event occured must be processed in similar manner regardless on which item experienced it. You may write similar triggers for each item but it seems to be much better to write it once on the higher level. Some events are block-specific so fire only for blocks, not for items. You may see your [pre|post]-[insert|update|delete] triggers on block and form level.
 
sem, thank you again. I believe you have helped a lot before.
One other question, if you don't mind.
So if I have a requirement that says:
after insert or update of column_Name
if t = 'Y' or r = '' then
message('do something');
end if;
How do you suggest I handle considering that it involves post-insert and post-update?
I wait for your valued response.
christi
 
Again, what trigger are you talking about?
"After insert or update" resembles database trigger, but message() is Forms built-in. If you're trying to validate item value in form before applying it (inserting or updating) you may use when-validate-item or when-validate-record triggers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top