From: | "Bart Degryse" <Bart(dot)Degryse(at)indicator(dot)be> |
---|---|
To: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: perlu: did I find a bug, or did I make one? |
Date: | 2007-06-04 14:58:43 |
Message-ID: | 466444C2.A3DD.0030.0@indicator.be |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Well, actually I do. If there's any error, I want nothing done.
But my real point was that although there are 2 records in my source table with dataareaid = 'lil' and two with dataareaid = 'bol' I still get 4 times the 'lil' error message, while I was expecting 2 times the 'lil' error message and two times the 'bol' error message.
>>> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> 2007-06-04 16:52 >>>
"Bart Degryse" <Bart(dot)Degryse(at)indicator(dot)be> writes:
> CREATE TRIGGER "afh_test_tr" BEFORE INSERT
> ON "public"."afh_test" FOR EACH ROW
> EXECUTE PROCEDURE "public"."temp_func1"();
>
> CREATE OR REPLACE FUNCTION "public"."temp_func1" () RETURNS trigger AS
> $body$
> BEGIN
> IF NEW.dataareaid =3D 'lil' THEN
> RAISE EXCEPTION '% foutje %', NEW.dataareaid, NEW.name;
> elsIF NEW.dataareaid =3D 'bol' THEN
> RAISE EXCEPTION '% nog een foutje %', NEW.dataareaid, NEW.name;
> END IF;
> RETURN NULL;
> END;
> $body$
> LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;
You probably don't want this trigger doing RETURN NULL; that's
turning all your inserts into no-ops.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Joshua | 2007-06-04 15:04:37 | current_date / datetime stuff |
Previous Message | Tom Lane | 2007-06-04 14:52:48 | Re: perlu: did I find a bug, or did I make one? |