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

Re: Serial columns and ADO

From: "Dmitriy Ivanov" <divanov-NOSP(at)M-aha(dot)ru>
To: pgsql-odbc(at)postgresql(dot)org
Subject: Re: Serial columns and ADO
Date: 2006-11-17 17:22:34
Message-ID: ejkrei$14kk$1@news.hub.org (view raw or flat)
Thread:
Lists: pgsql-odbc
Hello Dmitry,
"Dmitry Samokhin" <sdld(at)mail(dot)ru> wrote:

DS> But there's still another problem. Let our table 't1' be initially
DS> empty and the sequence reset to 1. Consider the following ADO operations:
DS>
DS>   rs.AddNew
DS>   rs("col2") = "Sample string"
DS>   rs.Update
DS>   MsgBox rs("col1")
DS>
DS>   rs.AddNew
DS>   rs("col1") = 2
DS>   rs("col2") = "Sample string"
DS>   rs.Update
DS>   MsgBox rs("col1")
DS>
DS> Look, the second insert operation sets the identity field
DS> explicitly. But the driver still lets 'SELECT currval...' to pass.
DS> As a result, my explicit value '2' is replaced by the currval()=1.
DS> Such distortion should be avoided anyway.

Generally, if you declared the column type as serial, you should not set it
explicitly while inserting records. In your example, rs.Update does not
guarantee changing the cursor position to the record inserted most recently.
(At least, with DAO against MS Access database.)  IMHO, it is not the ODBC
driver to blame.
--
Sincerely,
Dmitriy Ivanov



In response to

pgsql-odbc by date

Next:From: Andrew SatoriDate: 2006-11-17 19:25:54
Subject: Current Driver and Mac OS X Build questions
Previous:From: Dmitry SamokhinDate: 2006-11-17 08:22:56
Subject: Re: Serial columns and ADO

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