Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Last Insert ID in MS Access

by bobf (Monsignor)
on Jul 17, 2010 at 04:28 UTC ( #850063=note: print w/ replies, xml ) Need Help??


in reply to Last Insert ID in MS Access

Unfortunately, last_insert_rowid is not supported by the ODBC driver. When I need to do this I query for what I just inserted and get the ID that way.

I hope another monk can prove me wrong, as this approach is a bit cumbersome.


Comment on Re: Last Insert ID in MS Access
Download Code
Re^2: Last Insert ID in MS Access
by mje (Deacon) on Jul 19, 2010 at 08:26 UTC

    As you correctly say, last_insert_id is not supported by DBD::ODBC. The main reason for this is that there is no ODBC way to retrieve the last inserted ID. Each database and ODBC driver /may/ provide a way of obtaining it but support varies massively between databases and drivers (select @@identity, select myseq.currval from dual, insert ... returning, etc)

    As others have pointed out there may be ways of obtaining the last inserted id with MS Access but it rather depends on the version of access you are using and access method. This highlights again, why DBD::ODBC does not do it.

    If people want to send me SQL or other methods that work for different ODBC drivers and databases I will happily add them to the DBD::ODBC pod.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://850063]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (9)
As of 2014-07-22 08:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (108 votes), past polls