Menu

autonumber primary key

Charles
2006-02-11
2013-03-22
  • Charles

    Charles - 2006-02-11

    While inserting records to an MS Access database (1) does the autonumbering occur with ODBC? (2) How is the autonumber retrieved at insertion time (it cannot be retrieved later since there are no other unique fields to select on)? (3) If autonumbering does not occur in ODBC, how do I guarantee a unique number when many users are inserting to the database? As you can tell I am a newbie.

     
    • Roy Nurmi

      Roy Nurmi - 2006-02-13

      1) Autonumbering does occur with odbc.

      2) At least with tclodbc there is unfortunately no way to uniquely identify inserted record, if there are no unique fields to use in select clause.

      You could try starting a transaction before insert, and then do select max(autonumberfield) before commit. Depending on implementation, this could give you correct id even in multiuser environment. (just a hint, no guarantee)

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.