Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Getting identity after autoincr in FreeTDS/MSSQL/DBI

by Anonymous Monk
on Nov 09, 2001 at 22:43 UTC ( [id://124433]=note: print w/replies, xml ) Need Help??


in reply to Getting identity after autoincr in FreeTDS/MSSQL/DBI

I would bet that this is happening because you're trying to do both in one statement. try doing the insert, then grab the identity with a second call.. cooincidentally, my first post here spoke to this issue, albeit from Win32. Identity nabber for MSSQL
  • Comment on Re: Getting identity after autoincr in FreeTDS/MSSQL/DBI

Replies are listed 'Best First'.
Re: Re: Getting identity after autoincr in FreeTDS/MSSQL/DBI
by wardk (Deacon) on Nov 09, 2001 at 22:47 UTC
    hmmm, I guess I should login before posting, if I was wrong about the above blame anonymous monk...
      wardk,

      I think it is different when running over freeTDS on linux, because when I tried to do it as two seperate commands, @@IDENTITY was empty. I think it has something to do with the concept of "current session", but I don't really know.

      Nice work in Identity nabber for MSSQL, by the way.

      Thanks,
      Scott

        If the value for @@identity is empty when doing this as two requests it means that the select @@identity is done on a different physical connection from the insert. This usually happens when you don't completely flush all the results after the initial insert.

        I'm thinking of adding an attribute to DBD::Sybase that would inhibit the automatic secondary connections to handle multiple concurrent $sth on a single database handle as that causes quite a lot of confusion for people...

        Michael

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-23 17:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found