Re: Updating

From: Bob Pawley <rjpawley(at)shaw(dot)ca>
To: Daniel Verite <daniel(at)manitou-mail(dot)org>
Cc: Adrian Klaver <aklaver(at)comcast(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: Updating
Date: 2008-03-17 23:22:04
Message-ID: 020c01c88885$b5fa0b30$6401a8c0@owner
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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(at)manitou-mail(dot)org>
To: "Bob Pawley" <rjpawley(at)shaw(dot)ca>
Cc: "Adrian Klaver" <aklaver(at)comcast(dot)net>; <pgsql-general(at)postgresql(dot)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(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2008-03-17 23:32:28 Re: Moving pgstat.stat and pgstat.tmp
Previous Message Rodrigo Gonzalez 2008-03-17 22:39:09 Re: Problem with async notifications of table updates