in reply to "Getting Sql server identiy column value after insert

In your description you say:
Getting the identity column value of your last insert statement is tricky with DBI.

Do you say this because you tried the "last_insert_id" method in DBI and it didn't work for your particular database server? (If "$dbh" is your DBI handle, then  $dbh->last_insert_id(), with parameters needed for some servers, should return the autoincrement ID from the latest insert.)

Have you checked the DBD module that goes with your particular database server, to see whether there is any mention of an "insert_id" package variable?

It's true that the different database servers (and their respective DBD modules) have different behaviors with regard to the last_insert_id, but I think the issue is documented reasonably well in DBI as well as in the various DBD man pages. I know it works fine for mysql -- I use it all the time.

Apart from that, some people include use warnings (or the "-w" flag) in their scripts, which means that your assignment of a value to $id should probably go like this:

my $id = @idarray ? $idarray[0] : "undef";
so that the following "print" does not set off a warning about "Use of initialized value in print".