|Problems? Is your data what you think it is?|
Re: last_insert_id() in sybaseby erix (Prior)
|on Jul 12, 2014 at 11:00 UTC ( #1093359=note: print w/replies, xml )||Need Help??|
For some drivers the value may only be available if placeholders have not been used (e.g., Sybase, MS SQL). In this case the value returned would be from the last non-placeholder insert statement.
... and DBD::Sybase repeats:
last_insert_id() ignores any parameters passed to it, and will NOT return the last @@identity value generated in the case where placeholders were used, or where the insert was encapsulated in a stored procedure.
So apparently, for DBD::Sybase it's just not possible in combination with placeholders. Alas, I have no sybase instance to try it out.
You could give it a try without placeholders to make sure.
(FWIW, I work mostly with postgres, and its INSERT statement has the excellent RETURNING option, which makes it return the inserted row(s), or some columns thereof. But alas, that INSERT RETURNING option is a postgres addition, not found in other RDBMS (or SQL Standards)
Very handy. )
In Section Seekers of Perl Wisdom