Skip site navigation (1) Skip section navigation (2)

ADO and sequences

From: Andreas <maps(dot)on(at)gmx(dot)net>
To: pgsql-odbc(at)postgresql(dot)org
Subject: ADO and sequences
Date: 2006-08-22 17:38:18
Message-ID: 44EB410A.10809@gmx.net (view raw or flat)
Thread:
Lists: pgsql-odbc
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

     rs!field1 = value1
     rs!field2 = value2
....
rs.update
rs.close


Responses

pgsql-odbc by date

Next:From: JohannDate: 2006-08-22 19:20:50
Subject: Re: ADO and sequences
Previous:From: Rodney FranksDate: 2006-08-22 10:22:28
Subject: Re: Parameters.Refresh and RETURN setof TEXT

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group