Unix Technical Forum

obtaining the query string inside a trigger

This is a discussion on obtaining the query string inside a trigger within the pgsql Sql forums, part of the PostgreSQL category; --> Hi all. Im working on a "on each statement" update trigger, so NEW and OLD are NULL. Suppose a ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Sql

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 06:00 PM
Gerardo Herzig
 
Posts: n/a
Default obtaining the query string inside a trigger

Hi all. Im working on a "on each statement" update trigger, so NEW and
OLD are NULL.
Suppose a simple query like 'update mytable set id=id+500 where id <
50'...There is a way to obtaining the 'set id=..' and the where clause
in some way?

Thanks!
Gerardo

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 06:00 PM
Richard Huxton
 
Posts: n/a
Default Re: obtaining the query string inside a trigger

Gerardo Herzig wrote:
> Hi all. Im working on a "on each statement" update trigger, so NEW and
> OLD are NULL.
> Suppose a simple query like 'update mytable set id=id+500 where id <
> 50'...There is a way to obtaining the 'set id=..' and the where clause
> in some way?


Afraid not. It might be possible to implement in the simple case, but
what with views rewriting queries and triggers issuing their own
secondary queries it's not always obvious what "the" query would be.

What we really need is NEW and OLD as sets of affected rows in
statement-queries. Unfortunately that's not implemented yet either -
it's on the TODO I believe though.

--
Richard Huxton
Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:16 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com