Are we not allowed to use NEW and OLD in an EXECUTEd statement?

Postgresql 7.1 beta 4

Received:
ERROR:  NEW used in non-rule query

from within a plpgsql function (using an EXECUTE statement of course).

That aside, is there anyway to do:

v_var := NEW.v_variable;

As it would be an acceptable alternative.

--
Rod Taylor

There are always four sides to every story: your side, their side, the
truth, and what really happened.
Tue, 13 Feb 2001 13:13:53 -0500
"Rod Taylor" <rod.taylor@inquent.com>
NEW and OLD in EXECUTE
"Rod Taylor" <rod.taylor@inquent.com> writes:
> Are we not allowed to use NEW and OLD in an EXECUTEd statement?

Not for 7.1, I'm afraid.  EXECUTE doesn't provide *any* connection
to the plpgsql function's local namespace; it just hands off the
constructed string to the main SQL parser.

In most cases you can work around this by interpolating the variable's
value into the constructed string, eg,

	execute ''update foo set bar = '' || new.bar;

Use quote_literal() when interpolating a nonnumeric value this way.

I do have some ideas about improving the situation in 7.2 or later ...

			regards, tom lane

Tue, 13 Feb 2001 19:10:46 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Re: NEW and OLD in EXECUTE 