Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 086134758D8 for ; Sat, 10 Aug 2002 13:42:28 -0400 (EDT) Received: from gateway.idealcorp.com (66-192-27-146.gen.twtelecom.net [66.192.27.146]) by postgresql.org (Postfix) with ESMTP id 6D8FD4758C3 for ; Sat, 10 Aug 2002 13:42:27 -0400 (EDT) Received: from idealcorp.com (client07.office.ideal [192.168.1.17]) by gateway.idealcorp.com (8.12.3/8.12.3/Debian -4) with ESMTP id g7AHgRGd002344 for ; Sat, 10 Aug 2002 13:42:27 -0400 Message-ID: <3D555083.9040402@idealcorp.com> Date: Sat, 10 Aug 2002 13:42:27 -0400 From: Michael Zouroudis User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.8) Gecko/20020204 X-Accept-Language: en-us MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: problem with insertion of serial id Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/103 X-Sequence-Number: 5218 i've been stuck on a problem and i'm hoping that someone out there can help me out. my problem deals with three tables and one sequence. here are some example tables create table mom ( mom_id serial primary key ); create table dad ( dad_id serial primary key ); create table mom_dad( mom_id integer referenced from mom.mom_id dad_id integer referenced from dad.dad_id ); a trigger on mom sets off a function that inserts any relevent information into dad(my real tables obviously have more columns). my problem occurs when i try to put another trigger on dad that calls a function that inserts the id's of both tables into mom_dad. my function looks like this; create function parents() returns opaque as ' declare m mom%ROWTYPE; d dad%ROWTYPE; md mom_dad%ROWTYPE; mom_mom_id_seq%ROWTYPE; d_id integer; m_id integer; begin d_id := new.d_id; insert into mom_dad(m_id, d_id) values (currval('mom_mom_id_seq'), d_id); return null; end; 'language 'plpgsql'; create trigger family after insert or update on dad for each row execute procedure parents(); when i run this i get a parse error at or near "assets_asset_id_seq". i have also tried make a variable to represent the currval by using a select into statement, but couldn't get it to work. when i put a raise notice statement in the function and manually assign a value to m_id, it returns that value. otherwise, i do not know how to return the correct value(currval of m_id). i have looked at all docs on sequences and have not found an example that works correctly. i must be missing something. if anyone can help me out or point me in the right direction i would greatly appreicate it. thanks in advance, mikez -- Mike Z Intern __________________________________________________ I.D.E.A.L. Technology Corporation - Orlando Office http://www.idealcorp.com - 407.999.9870 x14