Re: Trigger unhappy (Correction)

From: Miguel que te importa <yourpadre(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Trigger unhappy (Correction)
Date: 2005-05-24 16:08:25
Message-ID: b623c7e40505240908798f7959@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

you have
NEW.updated = now();

and
NEW.indexed := false;

see "=" != ":=". maybe is the problem

2005/5/24, Bendik Rognlien Johansen <bendik(dot)johansen(at)gmail(dot)com>:
> Forgot to remove "OR" here IF NEW.indexed != true
>
> Hello,
> I have the following trigger on the table "records":
>
> CREATE OR REPLACE FUNCTION records_update_trigger() RETURNS TRIGGER AS '
> BEGIN
> NEW.updated = now();
> IF OLD.address1 != NEW.address1 OR OLD.postalcode1 !=
> NEW.postalcode1
> THEN
> RAISE NOTICE ''Address was altered, position set to null'';
> NEW.position := NULL;
> END IF;
>
> IF NEW.indexed != true
> THEN
> NEW.indexed := false;
> RAISE NOTICE ''Index not set, unsetting indexed'';
> END IF;
> RETURN NEW;
> END;
> ' language plpgsql;
>
> DROP TRIGGER update_trigger ON records;
> CREATE TRIGGER update_trigger BEFORE UPDATE ON records FOR EACH ROW
> EXECUTE PROCEDURE records_update_trigger();
>
> The "indexed" column on the table is default false.
> Every time i do an update, the variable NEW.indexed is true, even
> when it is not set in the sql. The result is that indexed is never
> set to false in the second if-clause of the function.
>
> What is causing this?
>
> Thanks
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
>

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2005-05-24 17:13:39 Re: Sparse Data
Previous Message Walker, Jed S 2005-05-24 15:57:58 Sparse Data