469,610 Members | 1,774 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,610 developers. It's quick & easy.

After update complete set

Hello list,

Is there a way in pg to fire a function when a complete (not row by row)
set is updated/inserted/deleted, for instance.

update order_detail set confirmed='S' where modifieddate=current_date;

Then after all the affected rows are updated, I need some code to
uptaded other tables from the information of the updated rows in the
details table.

Thanks in advance.

--
Sinceramente,
Josué Maldonado.

"Cuando los ricos se hacen la guerra, son los pobres los que mueren."
Jean Paul Sartre. Filósofo y escritor francés.

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #1
2 1167
Josué Maldonado wrote:
Hello list,

Is there a way in pg to fire a function when a complete (not row by
row) set is updated/inserted/deleted, for instance.

update order_detail set confirmed='S' where modifieddate=current_date;

Then after all the affected rows are updated, I need some code to
uptaded other tables from the information of the updated rows in the
details table.

Thanks in advance.

I'm interested in other's responce to this question as well.
I recently had to implement an equivelent trigger mechanism.
My solution consist of the following steps:
create an intermediate table to hold the minimum data needed for
single action trigger.
create a before trigger on insert, update, and delete which inserts
the needed data from the NEW construct if in insert or update and
inserts the needed data from OLD if in update or delete with a check for
prior existance (by the end of transaction this table is emptied).
create an after insert trigger on the intermediate table to perform
withever action is needed on the data, then delete the specific row in
the intermediate table.

The intermediate table would have a primary key which could be imposed
by a sequence (which I would set to cycle, so as long as you don't have
2^32, simultaneous transactions updating the base table you should be fine).

Hope this helps.
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #2
=?ISO-8859-1?Q?Josu=E9_Maldonado?= <jo***@lamundial.hn> writes:
Is there a way in pg to fire a function when a complete (not row by row)
set is updated/inserted/deleted,


Perhaps you want an AFTER STATEMENT trigger? Those are supported as of
7.4.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by William Wisnieski | last post: by
3 posts views Thread by Glen | last post: by
7 posts views Thread by gthompson | last post: by
5 posts views Thread by parwal.sandeep | last post: by
1 post views Thread by James Hallam | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.