Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Oracle trigger equivalent of MSSQL trigger

Oracle trigger equivalent of MSSQL trigger

From: Eric Patrick <epatrick_at_quandis.com>
Date: 24 Jun 2004 06:12:31 -0700
Message-ID: <3c42f1ed.0406240512.3bf4fcd0@posting.google.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US