X-Original-To: pgsql-interfaces-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id D530C9FA612 for ; Wed, 28 Jun 2006 15:05:57 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 06730-07 for ; Wed, 28 Jun 2006 15:05:52 -0300 (ADT) X-Greylist: delayed 00:05:02.418688 by SQLgrey- Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.188]) by postgresql.org (Postfix) with ESMTP id 60E369FA319 for ; Wed, 28 Jun 2006 15:05:52 -0300 (ADT) Received: from [84.187.148.9] (helo=gondolin) by mrelayeu.kundenserver.de (node=mrelayeu2) with ESMTP (Nemesis), id 0MKwtQ-1FveLH48EU-0001P9; Wed, 28 Jun 2006 20:00:48 +0200 From: Dirk Heinrichs To: pgsql-interfaces@postgresql.org Subject: plPerl: How to iterate over $_TD->{new} in a trigger function? Date: Wed, 28 Jun 2006 20:00:36 +0200 User-Agent: KMail/1.9.3 MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart2710874.nF0Ou0tBH5"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200606282000.43782.dirk.heinrichs@online.de> X-Provags-ID: kundenserver.de abuse@kundenserver.de login:c7bf8d9e07a8a90137e9341cdbcdc9ab X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/42 X-Sequence-Number: 6183 --nextPart2710874.nF0Ou0tBH5 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, I want to write a generic trigger function, which can be attached to any=20 table, but it seems I'm to stupid :-) to get column/value pairs out of=20 $_TD->{new} and $_TD->{old}. Here is my sample code: create or replace function test_trig() returns trigger as $$ elog (INFO, "Table is: $_TD->{relname}\n"); my %newrow =3D %_TD->{new}; elog (INFO, "$x=3D$y\n") while (($x,$y) =3D each %newrow); return; $$ language plperl; CREATE trigger trig1 after update or insert or delete on test for each row= =20 execute procedure test_trig(); Table test can be anything. This is what I get when I insert something: # insert into test (data) values ('foo'); INFO: Table is: test INFO: =3D INSERT 0 1 What I want to get at the second "INFO:" line is: INFO: data=3Dfoo Any hints? Thanks... Dirk --nextPart2710874.nF0Ou0tBH5 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.4 (GNU/Linux) iD8DBQBEosPL8NVtnsLkZ7sRAknLAJsGmC+x9ohcJHNfTkC2zwfsCgmsGQCghQbw Gngvrm7quD1oAB9c48kRErs= =CeXX -----END PGP SIGNATURE----- --nextPart2710874.nF0Ou0tBH5--