Iterating over rowtype/record fields? - Mailing list pgsql-general

From Bill Gribble
Subject Iterating over rowtype/record fields?
Date
Msg-id 1021554896.11133.12.camel@flophouse
Whole thread Raw
Responses Re: Iterating over rowtype/record fields?
List pgsql-general
I've looked online and in the 7.1 docs but I can't locate much
information about the RECORD type and what I can do with it from
pl/pgsql.  Are there any introspection or iteration functions that would
allow me to look at all the columns in a record without explicitly
writing RECORD.column?

I'm trying to write a fairly generic pl/pgsql trigger function to log
changes to a specified set of tables into another table.  So I can
easily get a NEW and OLD record, but in the generic case I don't know
what type of table they represent.  I'd like to just say something like

   FOR f IN table%ROWTYPE LOOP
     IF OLD.f != NEW.f THEN
       make_log_entry(table, NEW.rownum, f, NEW.f);
     END IF
   END LOOP

don't think that works tho :)

Any ideas how I can do something like the above?

Thanks,
Bill Gribble


pgsql-general by date:

Previous
From: Doug McNaught
Date:
Subject: Re: [INTERFACES] C & C ++Program Problem
Next
From: Tom Lane
Date:
Subject: Re: Iterating over rowtype/record fields?