Received: from smtp1.cluster.oleane.net (smtp1.cluster.oleane.net [195.25.12.16]) by hub.org (8.10.1/8.10.1) with ESMTP id e86AJPB83896 for ; Wed, 6 Sep 2000 06:19:29 -0400 (EDT) Received: from mbaroukh ([195.101.152.193]) by smtp1.cluster.oleane.net with SMTP id MAA59996; Wed, 6 Sep 2000 12:19:19 +0200 (CEST) Message-ID: <028b01c017ec$9bce6790$0102000a@ipanema.com> From: "Mike Baroukh" To: , References: <20000906202707.A4767@s2.enthdimension.com.au> Subject: Re: Trigger Date: Wed, 6 Sep 2000 12:24:15 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 X-Archive-Number: 200009/60 There is a sample in postgres documentation. (See below). the only problem is for using langage plpgsql. If it is not understand by your database, you must use command createlang plpgsql dbname as the owner of the database. CREATE TABLE emp ( empname text, salary int4, last_date datetime, last_user name); CREATE FUNCTION emp_stamp () RETURNS OPAQUE AS BEGIN -- Check that empname and salary are given IF NEW.empname ISNULL THEN RAISE EXCEPTION ''empname cannot be NULL value''; END IF; IF NEW.salary ISNULL THEN RAISE EXCEPTION ''% cannot have NULL salary'', NEW.empname; END IF; -- Who works for us when she must pay for? IF NEW.salary < 0 THEN RAISE EXCEPTION ''% cannot have a negative salary'', NEW.empname; END IF; -- Remember who changed the payroll when NEW.last_date := ''now''; NEW.last_user := getpgusername(); RETURN NEW; END; ' LANGUAGE 'plpgsql'; CREATE TRIGGER emp_stamp BEFORE INSERT OR UPDATE ON emp FOR EACH ROW EXECUTE PROCEDURE emp_stamp(); ----- Original Message ----- From: Craig May To: Sent: Wednesday, September 06, 2000 10:27 PM Subject: [SQL] Trigger > > Could someone send me a quick example of a trigger. >