cast record to array in plpgsql

From: Kurt <wazkelzu(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: cast record to array in plpgsql
Date: 2009-11-17 20:31:09
Message-ID: 4B03080D.6090100@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

dear list,

i'm trying to implement a general logging scheme with a plpgsql-trigger.
The idea is, that after an update the trigger compares the elements of
OLD and NEW and logs the changes made to the record columns. the trigger
should be usable by any table, so the field names are not known
beforehand. the natural solution seems to me to convert the records OLD,
NEW into 2-dimensional arrays where the second dimension is used to
address column-name and column_data and to step thru this array.
e.g. NEW{id=55;name='test'} would become a_new[1][1]='id;
a_new[1][2]=55; a_new[2][1]='name']; a_new[2][2] = 'test'.
as i think, that this should be quite a common problem, i would like to
ask whether some C-guru has already written a CAST-function for RECORD
to ARRAY, or has some better idea to solve this task.
thanks in advance, wz

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Naoko Reeves 2009-11-17 20:38:00 Re: does encrypt function support higher than basic ascii?
Previous Message Craig de Stigter 2009-11-17 20:18:05 Re: Corrupt indices on already-dropped table (could not open relation with OID ...)