create global temporary table in delete trigger
770384Jun 21 2010 — edited Jun 23 2010Hi 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