Re: [GENERAL] looping on NEW and OLD in a trigger

2010-08-28 Thread Merlin Moncure
On Sat, Aug 28, 2010 at 6:23 PM, Fabrízio de Royes Mello wrote: > 2010/8/28 Dmitriy Igrishin >> >> Hey Michael, >> >> As of PostgreSQL 9.0 you can do it from PL/pgSQL by >> using hstore module >> (http://www.postgresql.org/docs/9.0/static/hstore.html) >> >> I wrote an example for you: >> >> >> >

Re: [GENERAL] looping on NEW and OLD in a trigger

2010-08-28 Thread Fabrízio de Royes Mello
2010/8/28 Dmitriy Igrishin > Hey Michael, > > As of PostgreSQL 9.0 you can do it from PL/pgSQL by > using hstore module > (http://www.postgresql.org/docs/9.0/static/hstore.html) > > I wrote an example for you: > > > > Another way to do that is create a temp table from NEW or OLD record and loop

Re: [GENERAL] looping on NEW and OLD in a trigger

2010-08-28 Thread Dmitriy Igrishin
Hey Michael, As of PostgreSQL 9.0 you can do it from PL/pgSQL by using hstore module (http://www.postgresql.org/docs/9.0/static/hstore.html) I wrote an example for you: CREATE TABLE person(id integer, fname text, lname text, birthday date); CREATE TRIGGER person_test_trigger BEFORE INSERT ON

Re: [GENERAL] looping on NEW and OLD in a trigger

2010-08-26 Thread Merlin Moncure
On Thu, Aug 26, 2010 at 12:59 PM, Michael P. Soulier wrote: > On 26/08/10 Tom Lane did say: > >> If you're trying to do this in plpgsql, the answer is you can't. >> plpgsql doesn't support dynamic field references, which is what you'd >> need for what (I think) you're trying to do. >> >> You can d

Re: [GENERAL] looping on NEW and OLD in a trigger

2010-08-26 Thread Michael P. Soulier
On 26/08/10 Tom Lane did say: > If you're trying to do this in plpgsql, the answer is you can't. > plpgsql doesn't support dynamic field references, which is what you'd > need for what (I think) you're trying to do. > > You can do it in pltcl or plperl, and probably also plpython though > I don't

Re: [GENERAL] looping on NEW and OLD in a trigger

2010-08-26 Thread Tom Lane
"Michael P. Soulier" writes: > I'm very new to writing postgres procedures, and I'm trying to loop over > the fields in the NEW and OLD variables available in an after trigger, > and I can't quite get the syntax correct. If you're trying to do this in plpgsql, the answer is you can't. plpgsql do