Trigger Compile Error

From: "Mark Gilmore" <mgilmore(at)pobox(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Trigger Compile Error
Date: 2001-03-11 23:46:59
Message-ID: 98h355$28co$1@news.tht.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I have 2 identical postgresql databases (both 7.0.3) on 2 different server
(1 on Debian, 1 on Mandrake).

I have the same insert trigger and function on both databases. On the first
server the trigger works as intended, on the 2nd it fails and gives me a the
following error:

NOTICE: plpgsql: ERROR during compile of trigger_insert_customer near line
1
"RROR: parse error at or near "

Here is the SQL statements that were run (on both databases) to create the
trigger and corresponding function:

--
-- Function and trigger to enforce uniqueness of customer email
--
create function trigger_insert_customer()
RETURNS opaque
AS 'DECLARE
matches record;

BEGIN
IF new.cust_email IS NOT null THEN
IF (length(new.cust_email) > 0) THEN
SELECT INTO matches COUNT(*) FROM customer
WHERE customer.business_sakey = new.business_sakey AND
customer.cust_email = new.cust_email;

IF matches.count > 0 THEN
RAISE EXCEPTION ''Customer Email Already Exists for this
business. Email must be unique'';
END IF;
END IF;
END IF;
RETURN new;
END;'
LANGUAGE 'plpgsql';

CREATE TRIGGER trigger_insert_customer BEFORE INSERT ON customer
FOR EACH ROW
EXECUTE PROCEDURE trigger_insert_customer();

Again, it works on 1 database, but not the other. Both databases were
created from the same scripts, both have plpgsql created.

The trigger is to enforce uniqueness of email address, if one is present
(duplicate nulls and empty strings are allowable).

Any idea why I might be getting the parse error?

Thanks for the help!

Mark

--
Mark G. Gilmore
Software Development
TheImageGroup
mgilmore(at)imagegroup(dot)com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mark Stosberg 2001-03-12 00:45:55 tips document available for 6.5 to 7.0.x upgrade
Previous Message Marko Kreen 2001-03-11 23:04:19 [Announce] pgcrypto 0.3 (long)