Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 60FAC475F1A for ; Wed, 9 Oct 2002 05:37:55 -0400 (EDT) Received: from water.oasis.net.au (water.oasis.net.au [210.8.139.2]) by postgresql.org (Postfix) with ESMTP id 79C4847609C for ; Wed, 9 Oct 2002 05:37:43 -0400 (EDT) Received: from oasis.net.au (localhost [127.0.0.1]) by water.oasis.net.au (8.9.3/100.1) with ESMTP id UAA31938 for ; Wed, 9 Oct 2002 20:06:33 +1000 X-Authentication-Warning: water.oasis.net.au: Host localhost [127.0.0.1] claimed to be oasis.net.au From: "Rudi Starcevic" To: pgsql-sql@postgresql.org Subject: PLPGSQL errors Date: Wed, 9 Oct 2002 20:06:33 +1000 Message-Id: <20021009100633.M18916@oasis.net.au> X-Mailer: Open WebMail X-OriginatingIP: 203.221.163.217 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/120 X-Sequence-Number: 9837 Hi, I'm getting an error on a function I want to execute and I can't see why. I've tried a few different things and tweaked my sql without joy so far. I want to log all inserts or updates on one table to another table. Below I have my error, function , table schema and sql insert statement. Thanks It's a little long and I know anyone on this list has enough work of their own but what goes around comes around :-) error: [postgres@central postgres]$ /usr/local/pgsql/bin/psql demo -f sysinsert.sql psql:sysinsert.sql:16: NOTICE: Error occurred while executing PL/pgSQL function fn_sysmessages_log psql:sysinsert.sql:16: NOTICE: at END of toplevel PL block psql:sysinsert.sql:16: ERROR: control reaches end of trigger procedure without RETURN function : CREATE function fn_sysmessages_log() RETURNS OPAQUE AS ' BEGIN INSERT INTO sysmessages_log ( id, user_id, message_date, message_priority, message, status ) VALUES ( NEW.id, NEW.user_id, NEW.message_date, NEW.message_priority, NEW.message, NEW.status ); END; ' LANGUAGE 'plpgsql'; CREATE TRIGGER tr_sysmessages_log AFTER INSERT OR UPDATE ON sysmessages FOR EACH ROW EXECUTE PROCEDURE fn_sysmessages_log(); and my 2 tables : create table sysmessages ( id serial PRIMARY KEY, user_id integer NOT NULL, message_date date DEFAULT now() NOT NULL, message_priority char(1) CHECK( message_priority IN (1,2,3,4,5,6,7,8,9) ) NOT NULL, message text NOT NULL, status char(1) CHECK( status IN ('A','P','N') ) NOT NULL ); create table sysmessages_log ( log_id serial PRIMARY KEY, id integer, user_id integer NOT NULL, message_date date DEFAULT now() NOT NULL, message_priority char(1) CHECK( message_priority IN (1,2,3,4,5,6,7,8,9) ) NOT NULL, message text NOT NULL, status char(1) CHECK( status IN ('A','P','N') ) NOT NULL ); and the insert statement which is causing the error: INSERT INTO sysmessages ( user_id, message_date, message_priority, message, status ) VALUES ( 101, '2002-10-10', 1, 'hi', 'A' )