Skip site navigation (1) Skip section navigation (2)

Re: plPerl: How to iterate over $_TD->{new} in a trigger function?

From: Dirk Heinrichs <dirk(dot)heinrichs(at)online(dot)de>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: plPerl: How to iterate over $_TD->{new} in a trigger function?
Date: 2006-06-28 18:15:38
Message-ID: 200606282015.39032.dirk.heinrichs@online.de (view raw or flat)
Thread:
Lists: pgsql-interfaces
Am Mittwoch, 28. Juni 2006 20:00 schrieb Dirk Heinrichs:

> I want to write a generic trigger function, which can be attached to any
> table, but it seems I'm to stupid :-) to get column/value pairs out of
> $_TD->{new} and $_TD->{old}.

OK, got it myself.

> create or replace function test_trig() returns trigger as $$
>         elog (INFO, "Table is: $_TD->{relname}\n");
>         my %newrow = %_TD->{new};
	my %newrow = %{$_TD->{new}};
>         elog (INFO, "$x=$y\n") while (($x,$y) = each %newrow);
>         return;
> $$ language plperl;

Works as expected.

Bye...

	Dirk

In response to

pgsql-interfaces by date

Next:From: Francisco Figueiredo Jr.Date: 2006-06-28 19:05:29
Subject: Re: Npgsql MS 2.0 - char bug?
Previous:From: Dirk HeinrichsDate: 2006-06-28 18:00:36
Subject: plPerl: How to iterate over $_TD->{new} in a trigger function?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group