Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Oracle trigger equivalent of MSSQL trigger
I am porting a system from MSSQL to Oracle. Part of that system
includes the following scenario:
Tables: Event, EventQueue, MyTable
Trigger: MyTableEventInsert
The Event table contains rows that define web services to call. It contains (among other things) a column called AppliesToTable.
The MyTable table can be anything, but the idea is to check what events apply to MyTable inserts, and add a row to EventQueue for each event that applies to a MyTable inserted row.
The EventQueue is thus automatically populated by the MyTableEventInsert trigger, and can be processed by application code accordingly.
The MSSQL trigger works like a champ, and is constructed along these lines:
CREATE TRIGGER MyTableEventInsert ON MyTable
FOR INSERT
AS
INSERT INTO EventQueue (...)
SELECT (...)
FROM Inserted
INNER JOIN Event
ON Event.AppliesToTable = 'MyTable'
I would like to create the equivalent for Oracle.
My question is this: can I treat Oracle's NEW / OLD as logical tables, or do I need to process it along these lines:
CREATE OR REPLACE TRIGGER MyTableEventInsert
AFTER INSERT
ON MyTable
FOR EACH ROW
INSERT INTO EventQueue (...)
SELECT (...)
FROM MyTable
INNER JOIN Event
ON Event.AppliesToTable = 'MyTable'
WHERE MyTable.MyTableID = :new.MyTableID
Lastly, if I do it like my statement above, do the Oracle DBAs out there cringe at the performance implications? (This stikes me a much more cursor oriented than a nice, tight relational join.)
Thanks in advance,
Eric Received on Thu Jun 24 2004 - 08:12:31 CDT