INSERT BEFORE Trigger

From: Robert Fitzpatrick <robert(at)webtent(dot)com>
To: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: INSERT BEFORE Trigger
Date: 2004-06-19 15:32:03
Message-ID: 1087659123.3194.14.camel@columbus
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Anytime I create an INSERT BEFORE trigger that includes a query on the
same table as the trigger is assigned, the insert does not happen
without error. I get 'INSERT 0 0'. It is like the query loses the insert
information, is this something that can't be done?

DECLARE
checkit record;
BEGIN
SELECT INTO checkit MAX(public.tblhudunits.sort_order) AS maximum,
MIN(public.tblhudunits.sort_order) AS minimum FROM public.tblhudunits
WHERE (public.tblhudunits.hud_building_id = NEW.hud_building_id);
IF FOUND THEN
IF (NEW.sort_order >= checkit.minimum AND NEW.sort_order <=
checkit.maximum) THEN
RAISE EXCEPTION 'Sort Order cannot be between % and %',
checkit.minimum, checkit.maximum;
EXIT;
END IF;
END IF;
RETURN NULL;
END;

--
Robert

Responses

Browse pgsql-general by date

  From Date Subject
Next Message CN 2004-06-19 16:19:27 Re: Escape chars
Previous Message Kevin Murphy 2004-06-19 13:14:19 syntax error but command executes anyway?