pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mike Kock <mikekock@gmail.com>
To: pgsql-odbc@postgresql.org
Subject: Access and autonumbers (serial)
Date: Tue, 20 Jun 2006 10:07:57 -0700
Message-ID: <44556d330606201007w1fe11efdx5cf86c6c3a0424ae@mail.gmail.com> (raw)

If I open an ODBC connection using ADO, I am able to open a recordset
on a table with a serial type in it, do an AddNew, set my fields and
call Update.  At that point the serial field in the recordset is
populated with the newly allocated value.

Now, if I use Access's ADO connection object
(CurrentProject.Connection) which uses ODBC linked tables (linked
using the same ODBC connection string I used above) I get a "record is
deleted" error when I try to access the serial field in the recordset
after Update is called (running exact same code, just using a
different connection object).

I have tried to dig through the ODBC debug log and about the only
thing I can figure out is that straight ADO does a SQL_CURSOR_TYPE = 1
while the ODBC linked tables never set the cursor type value (so it is
defaulting to 0).  Also with all ADO I get dequeueNeedDataCallback
ret=0 count=2 after the insert (ODBC linked tables has count=0).  With
the non-zero count a query that looks like "SELECT * , "ctid",
"primary_key_serial_field_name" FROM table_name WHERE ctid =
currtid(0, '(,)')" is issued.  When the count is 0 this never happens.
 Instead a reselect of the original recordset open SQL is issued with
the extra criteria of primary_key_serial_field_name = null (since it
doesn't know the new serial value).

I have tried pretty much every Open recordset option with no luck.  I
also tried using DAO and the LastModified bookmark but this generates
the exact same error.  Anyone have any ideas on how to get the serial
value of a newly added record from an Access ODBC linked table?  Is
this difference happening because Access is not setting the cursor
type?  Is there any way to get a different default behavior?  I tried
looking through the ODBC code without much luck in finding much.
Thanks for any ideas or help.

Mike



Message-ID: <44556d330606201007w1fe11efdx5cf86c6c3a0424ae@mail.gmail.com>
Permalink:  ../44556d330606201007w1fe11efdx5cf86c6c3a0424ae@mail.gmail.com/
Also on:    postgresql.org/message-id/44556d330606201007w1fe11efdx5cf86c6c3a0424ae@mail.gmail.com

 · 

reply

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: mikekock@gmail.com
  Subject: Re: Access and autonumbers (serial)
  In-Reply-To: <44556d330606201007w1fe11efdx5cf86c6c3a0424ae@mail.gmail.com>
  References: <44556d330606201007w1fe11efdx5cf86c6c3a0424ae@mail.gmail.com>

* 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