X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 5D701D1B495 for ; Fri, 19 Dec 2003 11:39:35 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 88092-03 for ; Fri, 19 Dec 2003 07:38:48 -0400 (AST) Received: from smtp1.actcom.net.il (lmail.actcom.co.il [192.114.47.13]) by svr1.postgresql.org (Postfix) with ESMTP id F3E31D1B4B0 for ; Fri, 19 Dec 2003 07:38:28 -0400 (AST) Received: from shemesh.biz (line102-130.adsl.actcom.co.il [192.117.102.130]) by smtp1.actcom.net.il (8.12.8/8.12.8) with ESMTP id hBJBcNsW022197; Fri, 19 Dec 2003 13:38:24 +0200 Message-ID: <3FE2E32F.5080303@shemesh.biz> Date: Fri, 19 Dec 2003 13:38:23 +0200 From: Shachar Shemesh User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031107 Debian/1.5-3 X-Accept-Language: en, he MIME-Version: 1.0 To: Ropel Cc: postgre Subject: Re: get last oid References: <034201c3c5c3$de1e05f0$0200a8c0@bandeng> <002001c3c600$eb3f9c20$0100a8c0@ropelxp> <044a01c3c609$b4772ba0$0200a8c0@bandeng> <024501c3c60e$ebc9ab50$0100a8c0@ropelxp> In-Reply-To: <024501c3c60e$ebc9ab50$0100a8c0@ropelxp> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/54 X-Sequence-Number: 3592 Ropel wrote: >... In a well designed relational Db, every table has a (unique) primary >key: if so, you don't even need to >know the oid, because the record just inserted is directly reachable using >the PK. >If your PK uses sequences, you have to get the next seq value "select >nextval() from seq_xxxxx..." and use the >value obtained for inserting your new row instead of using it as a default >value; this way you are protected from >concurrent writing to the DB. > >If you REALLY need the oid from the ODBC connection, I can't help... sorry ! > >Bye > >Roberto > > > Actually, if you created the sequence implicitly by using the "serial" type, you don't even have to do that. You can simply do this: creating the table: create table foo (index serial not null, a type, b type.....); inserting into the table: insert into foo (a,b,....).... I.e. - leave the serial field out of the insert, and it will automatically be set to the next sequence from the table. -- Shachar Shemesh Open Source integration & consulting Home page & resume - http://www.shemesh.biz/