X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2464CD7255 for ; Fri, 2 Sep 2005 06:13:45 -0300 (ADT) 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 83860-06 for ; Fri, 2 Sep 2005 09:13:44 +0000 (GMT) Received: from SRVEXCHANGE.axis.hu (gate.axis.hu [195.228.194.36]) by svr1.postgresql.org (Postfix) with ESMTP id 3CFE7D6DAC for ; Fri, 2 Sep 2005 06:13:41 -0300 (ADT) Received: from [192.168.1.90] ([192.168.1.90]) by SRVEXCHANGE.axis.hu with Microsoft SMTPSVC(6.0.3790.0); Fri, 2 Sep 2005 11:09:37 +0200 Message-ID: <431816D1.4060905@axis.hu> Date: Fri, 02 Sep 2005 11:09:37 +0200 From: =?ISO-8859-2?Q?Graf_L=E1szl=F3?= User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Returning with the inserted id Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 8bit X-OriginalArrivalTime: 02 Sep 2005 09:09:37.0829 (UTC) FILETIME=[0B3EDD50:01C5AF9E] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.234 required=5 tests=[AWL=-0.023, FORGED_RCVD_HELO=0.05, UPPERCASE_25_50=0.207] X-Spam-Level: X-Archive-Number: 200509/8 X-Sequence-Number: 22555 Hi all A table was created with: CREATE TABLE test ( id integer, nev varchar(25), datum timestamp ); A sequence to hold the id was defined with: CREATE SEQUENCE "public"."test_azon_seq" INCREMENT 1 MINVALUE 101 MAXVALUE 9223372036854775807 START 101 CACHE 1; The function wich allocates the id and defines the datum is: CREATE FUNCTION test_verif() RETURNS trigger AS $test_verif$ BEGIN select into NEW.id nextval('test_azon_seq'); NEW.datum := current_timestamp; RETURN NEW; END; $test_verif$ LANGUAGE plpgsql; and the before insert trigger is: CREATE TRIGGER test_verif BEFORE INSERT ON test FOR EACH ROW EXECUTE PROCEDURE test_verif(); When I issue an insert (see below) how can I retrieve the inserted value of id? I need something like Oracle's returns for insert. insert into "public"."test" (nev) values ('text'); -- László Graf