dbTalk Databases Forums  

Query table within trigger...

comp.database.oracle comp.database.oracle


Discuss Query table within trigger... in the comp.database.oracle forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Aiden Fung
 
Posts: n/a

Default Query table within trigger... - 08-20-2004 , 05:27 PM






Is there a way to query the uncommitted result set of the triggered table
through a non row based trigger?

For example:

CREATE OR REPLACE TRIGGER ABC_Trigger
AFTER INSERT OR UPDATE OR DELETE ON ABC_Table
DECLARE

i NUMBER;

BEGIN
SELECT COUNT(1) INTO i FROM ABC_Table;
DBMS_OUTPUT.PUT_LINE(i);
END ABC_Trigger;


From this example, the variable "i" will always have the original row count
of the table before any records being inserted or removed. Is there a way to
get the final record count (the uncommited result) of the table within the
trigger? Please note that this is a non row based trigger since I only want
it to trigger once disregarding the number of records being inserted or
deleted.

Thanks in advance,
Aiden



Reply With Quote
  #2  
Old   
Theo
 
Posts: n/a

Default Re: Query table within trigger... - 08-22-2004 , 01:14 PM






Aiden Fung wrote:
Quote:
Is there a way to query the uncommitted result set of the triggered
table through a non row based trigger?

For example:

CREATE OR REPLACE TRIGGER ABC_Trigger
AFTER INSERT OR UPDATE OR DELETE ON ABC_Table
DECLARE

i NUMBER;

BEGIN
SELECT COUNT(1) INTO i FROM ABC_Table;
DBMS_OUTPUT.PUT_LINE(i);
END ABC_Trigger;


From this example, the variable "i" will always have the original row
count of the table before any records being inserted or removed.
No it doesn't. It will have the rowcount after the insert/delete.
It is definied as an _AFTER_ insert/update/delete trigger.

Quote:
Is there a way to get the final record count (the uncommited result) of
the table within the trigger? Please note that this is a non row
based trigger since I only want it to trigger once disregarding the
number of records being inserted or deleted.
The trigger does exactly what you want.

--
Theo




Reply With Quote
  #3  
Old   
Aiden Fung
 
Posts: n/a

Default Re: Query table within trigger... - 08-23-2004 , 12:38 PM



Sorry, I forgot that my original trigger has the PRAGMA
AUTONOMOUS_TRANSACTION declared. After removing the pragma, everything seems
to work fine.

Thanks!
Aiden

"Theo" <theoa_nl (AT) hotmail (DOT) com> wrote

Quote:
Aiden Fung wrote:
Is there a way to query the uncommitted result set of the triggered
table through a non row based trigger?

For example:

CREATE OR REPLACE TRIGGER ABC_Trigger
AFTER INSERT OR UPDATE OR DELETE ON ABC_Table
DECLARE

i NUMBER;

BEGIN
SELECT COUNT(1) INTO i FROM ABC_Table;
DBMS_OUTPUT.PUT_LINE(i);
END ABC_Trigger;


From this example, the variable "i" will always have the original row
count of the table before any records being inserted or removed.

No it doesn't. It will have the rowcount after the insert/delete.
It is definied as an _AFTER_ insert/update/delete trigger.

Is there a way to get the final record count (the uncommited result) of
the table within the trigger? Please note that this is a non row
based trigger since I only want it to trigger once disregarding the
number of records being inserted or deleted.

The trigger does exactly what you want.

--
Theo





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.