X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B769A3A55DA for ; Mon, 10 Jan 2005 14:13:53 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 30985-05 for ; Mon, 10 Jan 2005 14:13:45 +0000 (GMT) Received: from ns.ceti.pl (ns.ceti.pl [62.121.128.50]) by svr1.postgresql.org (Postfix) with ESMTP id C60A43A55C2 for ; Mon, 10 Jan 2005 14:13:47 +0000 (GMT) Received: from tech.ceti.pl (echo7.ceti.pl [62.121.128.47]) by ns.ceti.pl (Postfix) with ESMTP id 0916E9E7A8 for ; Mon, 10 Jan 2005 15:13:47 +0100 (CET) Message-ID: <41E28E05.2040307@tech.ceti.pl> Date: Mon, 10 Jan 2005 15:15:33 +0100 From: =?ISO-8859-2?Q?Jarek_Pude=B3ko?= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; PL; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: pl, en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: return value of the trigger function Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200501/105 X-Sequence-Number: 19893 Hi I have big problem with a trigger function. Defs: CREATE TABLE foo (id int2, name varchar(20)); foo.id cannot be serial or autoint because it will not be unique. Now I need a trigger that return foo.id of the inserted record. INSERT INTO foo VALUES (max(foo.id)+1,'junk'); IMHO the trigger should be: CREATE TRIGGER tr_get_new_id AFTER INSERT on foo ON EACH ROW EXECUTE PROCEDURE get_new_id(); But I cannot create the function :( I don't know what type should be input and how about output? trigger or int2? TIA, -- Jarek Pudelko JP272-RIPE