Home » SQL & PL/SQL » SQL & PL/SQL » Trigger to operate on multiple tables, via OR
Trigger to operate on multiple tables, via OR [message #36504] Fri, 30 November 2001 10:42 Go to next message
mtower_in_houston
Messages: 2
Registered: November 2001
Junior Member
I want to tell my trigger to operate
If there's an update to table1
-OR -
If there's an update to table2
-OR -
If there's an update to table3

But I can't seem to find a way to do that, using

CREATE OR REPLACE TRIGGER trig_update_sales
AFTER UPDATE ON table1
OR AFTER UPDATE ON table2
FOR EACH ROW

Tweaking the syntax doesn't seem to help. Maybe you just can't do it. Does anyone know? Thanks.

----------------------------------------------------------------------
Re: Trigger to operate on multiple tables, via OR [message #36505 is a reply to message #36504] Fri, 30 November 2001 11:01 Go to previous messageGo to next message
Suresh Vemulapalli
Messages: 624
Registered: August 2000
Senior Member
you have to create 3 separate triggers, that's only way.

----------------------------------------------------------------------
Re: Trigger to operate on multiple tables, via OR [message #36516 is a reply to message #36505] Sun, 02 December 2001 21:56 Go to previous messageGo to next message
Rob Baillie
Messages: 33
Registered: November 2001
Member
You can, of course, call a procedure from a trigger.

So... write 1 procedure and call it from all three triggers.

----------------------------------------------------------------------
Re: Trigger to operate on multiple tables, via OR [message #36533 is a reply to message #36505] Mon, 03 December 2001 06:05 Go to previous message
mtower_in_houston
Messages: 2
Registered: November 2001
Junior Member
Thanks, Roy. However, the project specifically calls for writing only ONE trigger. This trigger is to operate when any of the four tables is updated. I handled it this way:

I wrote four separate procedures: one for each table. Each of the four procedures writes to an audit table. The triggers (only one trigger) operates off the audit table, rather than operating off the original four tables.

----------------------------------------------------------------------
Previous Topic: How to copy data from remote database to my local system
Next Topic: procedure
Goto Forum:
  


Current Time: Thu Mar 28 09:07:47 CDT 2024