By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,176 Members | 984 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,176 IT Pros & Developers. It's quick & easy.

Specify a column without using its name

P: n/a
Hi all!

I'm trying to write a general-purpose trigger that determines what fields have
changed during an UPDATE, but I'm running into a problem.

I'm trying to dynamically select the value from a field in "old" and "new" (the
old and new values for the changed row), but I can't figure out how to do so.

I tried something like,

qry := ''SELECT '' || fieldname || '' AS curval FROM old'';
FOR rec IN EXECUTE qry LOOP
fieldval := rec.curval;
EXIT;
END LOOP;

but it doesn't work ("ERROR: OLD used in non-rule query").

Any suggestions?

Thanks,

Andrew


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Andrew Biagioni <an*************@e-greek.net> writes:
I'm trying to write a general-purpose trigger that determines what fields have
changed during an UPDATE, but I'm running into a problem.


You cannot do this in plpgsql. It's possible in pltcl though.

regards, tom lane

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

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.