Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

create global temporary table in delete trigger

770384Jun 21 2010 — edited Jun 23 2010
Hi to all, I am triyng to create a global temporary table in trigger so i can hold all the deleted rows and do some stuff after the statement which uses the table that fires the trigger.
In this way I am trying to avod mutating table error. but the following trigger gives error.

create or replace
TRIGGER TD_EKSINAVLAR
FOR DELETE ON DERSSECIMI_EKSINAVLAR
COMPOUND TRIGGER

BEFORE STATEMENT IS
BEGIN

CREATE GLOBAL TEMPORARY TABLE DELETED_ROWS
AS ( SELECT * FROM DERSSECIMI_EKSINAVLAR WHERE 1 = 2 )
ON COMMIT DELETE ROWS;

END BEFORE STATEMENT;

BEFORE EACH ROW IS
BEGIN

NULL;

END BEFORE EACH ROW;

AFTER EACH ROW IS
BEGIN

NULL;

END AFTER EACH ROW;

AFTER STATEMENT IS
BEGIN

NULL;

END AFTER STATEMENT;

END TD_EKSINAVLAR;

the error is

Error(12,5): PLS-00103: Encountered the symbol "CREATE" when expecting one of the following: ( begin case declare exit for goto if loop mod null pragma raise return select update while with <an identifier> <a double-quoted delimited-identifier> <a bind variable> << continue close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe purge

Please help me about the situation.
Thanks in advance.

Gokhan
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 21 2010
Added on Jun 21 2010
10 comments
1,456 views