Skip to Content.
Sympa Menu

freetds - Equivalent of mysql_insertid using FreeTDS/DBD::Sybase?

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Richard Wolfe" <rwolfe AT resourceprint.com>
  • To: "TDS Development Group" <freetds AT franklin.metalab.unc.edu>
  • Subject: Equivalent of mysql_insertid using FreeTDS/DBD::Sybase?
  • Date: Mon, 30 Sep 2002 17:19:38 -0500


I am using FreeTDS/DBD::Sybase to let my CGI Perl script on a webserver make
inserts into a MS SQL Server db running on a remote machine. Everything is
up and running hunky-dory, no small thanks to the good folks of this forum
for helping me install/configure everything. One issue though...

One of the tables I'm inserting into has an auto-incrementing integer field
that is its primary key. In the past (when accessing a MySQL db, my only
real database experience), I'm used to doing something like this to get the
value of that generated field when I make the insert:

$SQL = "INSERT INTO mytable (name, address) VALUES('joe blow', '1234 main
street')";
$sth = $dbh->prepare($SQL);
$rc = $sth->execute;
$newid = $sth->{mysql_insertid};
$sth->finish;

...where $newid returns the value of the auto-incrementing field. Is there
an equivalent function in DBD::Sybase? The pod file says something about
@@IDENTITY, but I can't get this to work. Am I on the right track?

Thanks in advance,
Richard






Archive powered by MHonArc 2.6.24.

Top of Page