[GENERAL] field incrementing in a PL/pgSQL trigger

2004-10-30 Thread Tim Vadnais
Title: field incrementing in a PL/pgSQL trigger Hi, My boss wants to add some logging functionality to some of our tables on update/delete/insert.  I need to log who, when, table_name, field name, original value and new value for each record, but only logging modified fields, and he wants m

Re: [GENERAL] field incrementing in a PL/pgSQL trigger

2004-10-28 Thread Michael Fuhr
On Thu, Oct 28, 2004 at 09:14:17AM -0700, Tim Vadnais wrote: > > My questions are: Is there a way I can dynamically determine the number of > fields in the rows that is being maintained. (a function much like: > PQnfields(const PGresult *); ) > Then I need a way to get the name of the field (using

Re: [GENERAL] field incrementing in a PL/pgSQL trigger

2004-10-28 Thread Tom Lane
"Tim Vadnais" <[EMAIL PROTECTED]> writes: > My questions are: Is there a way I can dynamically determine the number of > fields in the rows that is being maintained. I'm starting to think there should be a FAQ entry for this ;-) plpgsql is essentially incapable of doing anything that involves dyn

[GENERAL] field incrementing in a PL/pgSQL trigger

2004-10-28 Thread Tim Vadnais
Hi, My boss wants to add a special type of logging to some of our tables on update/delete/insert. I need to log who, when, table_name, field name, original value and new value for each record, but only logging modified fields, and he wants me to do this using postgres pgSQL triggers. The changes

Re: [GENERAL] field incrementing in a PL/pgSQL trigger

2004-10-23 Thread Pierre-Frédéric Caillaud
Create a different trigger function for each table, then each trigger can be customized to know the column names. You can generate the triggers from a little script which queries the system tables to get at the column names. It would spit code like 'IF NEW.fieldname != OLD.fieldname THEN (

Re: [GENERAL] field incrementing in a PL/pgSQL trigger

2004-10-23 Thread Tom Lane
"Tim Vadnais" <[EMAIL PROTECTED]> writes: > My questions are: Is there a way I can dynamically determine the number of > fields in the row that is being maintained. (a function much like: > PQnfields(const PGresult *); ) > Then I need a way to get the name of the field (using a function much like:

[GENERAL] field incrementing in a PL/pgSQL trigger

2004-10-23 Thread Tim Vadnais
Hi, My boss wants to add some logging functionality to some of our tables on update/delete/insert. I need to log who, when, table_name, field name, original value and new value for each record, but only logging modified fields, and he wants me to do this wing postgres pgSQL triggers. We are give