starting a stored procedure+rule AFTER an insert

Started by Bima Djaloeisover 18 years ago3 messagesgeneral
Jump to latest
#1Bima Djaloeis
bima.djaloeis.uni@googlemail.com

Hi, Newbie here,

I have implemented a stored procedure that writes out the newest DB entry on
insert, and combined it with a rule.

1) create function newcache() returns void AS 'newCache', 'newCache'
language c;
2) create rule newcacherule AS on insert to caches do also select
newcache();

The problem is that newcacherule fires BEFORE the insert has taken place, so
effectively, I always just get the 2nd newest entry to write into my text
file while the newest entry is "stuck in the queue" until a new insert come.
How can I execute my rule AFTER the insert has taken place?

Thanks for reading!

#2Doug McNaught
doug@mcnaught.org
In reply to: Bima Djaloeis (#1)
Re: starting a stored procedure+rule AFTER an insert

"Bima Djaloeis" <bima.djaloeis.uni@googlemail.com> writes:

I have implemented a stored procedure that writes out the newest DB
entry on insert, and combined it with a rule.

1) create function newcache() returns void AS 'newCache', 'newCache' language
c;
2) create rule newcacherule AS on insert to caches do also select newcache();

The problem is that newcacherule fires BEFORE the insert has taken
place, so effectively, I always just get the 2nd newest entry to
write into my text file while the newest entry is "stuck in the
queue" until a new insert come. How can I execute my rule AFTER the
insert has taken place?

Rules effectively happen at query parse time. You probably want an
AFTER trigger instead.

-Doug

#3Bima Djaloeis
bima.djaloeis.uni@googlemail.com
In reply to: Doug McNaught (#2)
Re: starting a stored procedure+rule AFTER an insert

Thanks for the reply, is there any online reference / tutorial for this?

-BD

2007/10/8, Douglas McNaught <doug@mcnaught.org>:

Show quoted text

"Bima Djaloeis" <bima.djaloeis.uni@googlemail.com> writes:

I have implemented a stored procedure that writes out the newest DB
entry on insert, and combined it with a rule.

1) create function newcache() returns void AS 'newCache', 'newCache'

language

c;
2) create rule newcacherule AS on insert to caches do also select

newcache();

The problem is that newcacherule fires BEFORE the insert has taken
place, so effectively, I always just get the 2nd newest entry to
write into my text file while the newest entry is "stuck in the
queue" until a new insert come. How can I execute my rule AFTER the
insert has taken place?

Rules effectively happen at query parse time. You probably want an
AFTER trigger instead.

-Doug