Following is the code that gives me the error.
CREATE OR REPLACE FUNCTION monitor_install() RETURNS trigger AS $$
Begin
If NEW.p_id.association.monitoring_fluid is distinct from
Old.p_id.association.monitoring_fluid Then
INSERT INTO p_id.devices (device_number)
(Select mon_function from p_id.association, p_id.devices
Where (p_id.association.mon_function <> p_id.devices.device_number
and (p_id.association.monitoring_fluid <> p_id.devices.fluid_id
or p_id.association.monitoring_fluid <> p_id.devices.pipe_id))
and p_id.association.monitor is null);
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
create trigger monitorinstall before update on p_id.association
for each row execute procedure monitor_install();
----- Original Message -----
From: "Daniel Verite" <daniel@manitou-mail.org>
To: "Bob Pawley" <rjpawley@shaw.ca>
Cc: "Adrian Klaver" <aklaver@comcast.net>; <pgsql-general@postgresql.org>
Sent: Monday, March 17, 2008 2:42 PM
Subject: Re: [GENERAL] Updating
> Bob Pawley wrote:
>
>> I am attempting to use the following code but I get -
>> "ERROR: NEW used in query that is not in a rule".
>>
>> This implies that I create a rule for NEW and OLD (which I haven't
> needed
>> before).
>
> No, but are you sure you're using these keywords in the context of a
> plpgsql function?
> Can you post the entire CREATE statement that fails?
>
>> BTW I noticed that Adrian used != . Is this symbol the same as <> ?
>
> Yes it's the same.
>
> Best regards,
> --
> Daniel
> PostgreSQL-powered mail user agent and storage:
> http://www.manitou-mail.org
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general