Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re^2: last_insert_id() in sybase

by roboticus (Chancellor)
on Jul 12, 2014 at 11:34 UTC ( #1093362=note: print w/replies, xml ) Need Help??

in reply to Re: last_insert_id() in sybase
in thread last_insert_id() in sybase

If I recall correctly, when I used Sybase (about 12 years ago) I used to do it like this:

my $SQL = <<EOSQL; begin insert into foo (col1, uniquecol) values (?, ?); select id from foo where uniquecol=?; end EOSQL my $ST = $DB->prepare($SQL); $ST->execute('abacus', 'S/N5842', 'S/N5842'); while (my $hr = $ST->fetchrow_hasharray) { print "ID is $$hr{ID}\n"; }

Since it's executed in a transaction, there isn't a race condition. However, you *do* need to be able to uniquely identify the row without using it's ID--by using a unique (group of) column(s).


When your only tool is a hammer, all problems look like your thumb.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2023-09-28 19:59 GMT
Find Nodes?
    Voting Booth?

    No recent polls found