NEW used in a query that is not in a rule - Mailing list pgsql-hackers

From Gaetano Mendola
Subject NEW used in a query that is not in a rule
Date
Msg-id 414739B8.1070406@bigfoot.com
Whole thread Raw
Responses Re: NEW used in a query that is not in a rule
List pgsql-hackers
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,
I'm bouncing on the following problem, I don't know if is a bug or if exist a different
way to do it.
The following code is not meaningfull but it's an extract of what I'm trying to do:


CREATE TABLE foo ( field1 INTEGER );

CREATE OR REPLACE FUNCTION trigger_foo()
RETURNS TRIGGER AS'
DECLARE

~   my_field TEXT;
~   my_stat  TEXT;

BEGIN

~   my_field = TG_ARGV[0];

~   my_stat = ''SELECT field1 FROM foo where field1 = NEW.'' || my_field;

~   EXECUTE my_stat;

~   RETURN NEW;


END;
' LANGUAGE 'plpgsql';


CREATE TRIGGER check_foo
BEFORE INSERT ON foo
FOR EACH ROW EXECUTE PROCEDURE trigger_foo('field1');

insert into foo values ( 3 );


I got the error in the subject, it's like the EXECUTE open another contest and
forget that is inside a rule.

Any idea someone ?




Regards
Gaetano Mendola









-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBRzm37UpzwH2SGd4RAnObAKD4G6S6MdvaYsGxjS88sn+u2OJqagCg86ut
tsa/AXBfKtB12sCPBIwJAYc=
=G2DY
-----END PGP SIGNATURE-----



pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Is select a transaction starting statement?
Next
From: Dennis Bjorklund
Date:
Subject: Re: Is select a transaction starting statement?