Unix Technical Forum

Serial columns and ADO

This is a discussion on Serial columns and ADO within the pgsql Interfaces odbc forums, part of the PostgreSQL category; --> Hello Dmitry, "Dmitry Samokhin" <sdld@mail.ru> wrote: DS> But there's still another problem. Let our table 't1' be initially DS> ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Interfaces odbc

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #11 (permalink)  
Old 04-16-2008, 03:12 AM
Dmitriy Ivanov
 
Posts: n/a
Default Re: Serial columns and ADO

Hello Dmitry,
"Dmitry Samokhin" <sdld@mail.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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:54 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com