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.
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...