X-Original-To: pgsql-odbc-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id ABA9F9FB233 for ; Wed, 23 Aug 2006 05:49:51 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 61459-02 for ; Wed, 23 Aug 2006 05:49:43 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sd.tpf.co.jp (smtp.tpf.co.jp [210.161.239.34]) by postgresql.org (Postfix) with SMTP id 88F659FB20C for ; Wed, 23 Aug 2006 05:49:42 -0300 (ADT) Received: (qmail 31969 invoked from network); 23 Aug 2006 17:49:40 +0900 Received: from unknown (HELO ?100.0.32.123?) (100.0.32.123) by sd2.tpf-fw-c.co.jp with SMTP; 23 Aug 2006 17:49:40 +0900 Message-ID: <44EC1689.8080907@tpf.co.jp> Date: Wed, 23 Aug 2006 17:49:13 +0900 From: Hiroshi Inoue User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) MIME-Version: 1.0 To: Andreas CC: pgsql-odbc@postgresql.org Subject: Re: ADO and sequences References: <44EB410A.10809@gmx.net> In-Reply-To: <44EB410A.10809@gmx.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.848 tagged_above=0 required=5 tests=AWL, RCVD_IN_WHOIS_BOGONS X-Spam-Level: * X-Archive-Number: 200608/81 X-Sequence-Number: 8045 Andreas wrote: > Hi, > > I'd like to write to PG from Access2000 with ADODB. > I got it running, but I'd like to know the sequence-nr that gets used > when a new record is created. > > I open a recordset with > .CursorLocation = adUseClient > .CursorType = adOpenStatic > .LockType = adLockOptimistic > then I call its AddNew method, the columns get filled and the recordset > is closed. > The primary key is a SERIAL. > Is there a way to read the pkey before I commit the record? > Access knows it's Autonumbers after AddNew when I use it's JET db-engine. > > A "select currval...." after the AddNew yields > Error while executing the query; > ERROR: currval of sequence "personen_person_id_seq" is not yet defined > in this session > > I'd rather not use currval anyways. I'd prefer to have the program not > know to much of the structure that sits in the db backend, like the > sequence's name in this case. > > Can I get something like this : > > rs.AddNew > lngID = rs!id Try to get rs!id here is meaningless but > rs!field1 = value1 > rs!field2 = value2 > .... > rs.update you can get rs!id here maybe. Am I misunderstanding your point ? > rs.close regards, Hiroshi Inoue