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

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

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



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

Attachment: pgpjRrl4Ci3Oh.pgp
Description: PGP signature



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group