"OLD used in query that is not in a rule"

Started by Gauthier, Daveabout 14 years ago3 messagesgeneral
Jump to latest
#1Gauthier, Dave
dave.gauthier@intel.com

I get... "OLD used in query that is not in a rule" when trying to ref, for example, OLD.tblcol1, from inside a stored procedure. Is this saying you cannot use OLD.* (or NEW.* I suppose) unless it's from within a trigger function (returns type "trigger")?

If so, is there some way to tap this info given that the stored procedure is running as part of a check constraint definition?

Thanks for any help.

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Gauthier, Dave (#1)
Re: "OLD used in query that is not in a rule"

"Gauthier, Dave" <dave.gauthier@intel.com> writes:

I get... "OLD used in query that is not in a rule" when trying to ref, for example, OLD.tblcol1, from inside a stored procedure. Is this saying you cannot use OLD.* (or NEW.* I suppose) unless it's from within a trigger function (returns type "trigger")?

Certainly. You'd have to pass the field (or whole record) as a
parameter. It's not some kind of magic global variable, it's
a predefined local variable in a trigger function (or rule).

regards, tom lane

#3Gauthier, Dave
dave.gauthier@intel.com
In reply to: Tom Lane (#2)
Re: "OLD used in query that is not in a rule"

OK, and understood.
And yes, I thought it was a global.

Thanks Tom.

-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent: Monday, March 26, 2012 10:52 AM
To: Gauthier, Dave
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] "OLD used in query that is not in a rule"

"Gauthier, Dave" <dave.gauthier@intel.com> writes:

I get... "OLD used in query that is not in a rule" when trying to ref, for example, OLD.tblcol1, from inside a stored procedure. Is this saying you cannot use OLD.* (or NEW.* I suppose) unless it's from within a trigger function (returns type "trigger")?

Certainly. You'd have to pass the field (or whole record) as a
parameter. It's not some kind of magic global variable, it's
a predefined local variable in a trigger function (or rule).

regards, tom lane