From: Hiroshi Inoue <inoue@tpf.co.jp>
To: Andreas <maps.on@gmx.net>
Cc: pgsql-odbc@postgresql.org
Subject: Re: ADO and sequences
Date: Wed, 23 Aug 2006 17:49:13 +0900
Message-ID: <44EC1689.8080907@tpf.co.jp> (raw)
In-Reply-To: <44EB410A.10809@gmx.net>
References: <44EB410A.10809@gmx.net>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-odbc@postgresql.org
Cc: inoue@tpf.co.jp, maps.on@gmx.net
Subject: Re: ADO and sequences
In-Reply-To: <44EC1689.8080907@tpf.co.jp>
References: <44EB410A.10809@gmx.net> <44EC1689.8080907@tpf.co.jp>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox