|Perl Monk, Perl Meditation|
Re^2: last_insert_id() in sybaseby mpeppler (Vicar)
|on Jul 23, 2014 at 19:21 UTC ( #1094843=note: print w/replies, xml )||Need Help??|
To explain a bit further - the @@identity value is local to the execution context in Sybase ASE. In this case an execution context is the current "batch" (i.e. set of raw SQL statements to be executed as a single operation), or the current SQL proc. In case of nested proc calls each proc gets its own copy of @@identity.
When you insert data into a table using placeholders DBD::Sybase uses the Sybase ct_dynamic() API - this has the side effect of creating a temporary stored proc on the server, and then executing this proc however many times you call the execute() method.
At one point Tim Bunce suggested doing a
to get the most recent value from the table, but there is absolutely no guarantee that this would be your insert - in a high volume environment you could very well have several inserts from different clients that happen between the insert and the select.
In Section Seekers of Perl Wisdom