in reply to Re: last_insert_id() in sybase
in thread last_insert_id() in sybase
This a test script in sybase database using perl DBI module
my $dbh = DBI->connect( "dbi:Sybase:server=$dbServer;hostname=$hostname;database=cle +aringdb", $dbUser, $dbPasswd->[1],{AutoCommit => 1}); my $insertStatement = $dbh->prepare("INSERT INTO BatchFile (FileName,F +ileStatusCode,FileDate,FileFormatCode,TotalRecords,LoadStartTime,Modi +fiedDate,ModifiedBy) VALUES ('Akash',4,GetDate(),0,3,GetDate(),GetDat +e(),'FIX2MQ')") or $DBI::err and die($DBI::errstr); my $id = $dbh->last_insert_id(undef,undef,undef,undef) or die "no inse +rt id $DBI::errstr $!"; print "ID : ",$id; my $updateStatement = $dbh->prepare("UPDATE BatchFile SET FileStatusC +ode = ? ,ModifiedDate = GETDATE(),TotalRecords = ? WHERE BatchFileID += ?"); $updateStatement->execute(6,1,$id) or die($DBI::errstr); $insertStatement->finish(); $updateStatement->finish(); my $rc = $dbh->disconnect or die($DBI::errstr);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: last_insert_id() in sybase
by boftx (Deacon) on Jul 12, 2014 at 05:24 UTC | |
by Shreyak (Novice) on Jul 12, 2014 at 07:01 UTC | |
by boftx (Deacon) on Jul 12, 2014 at 07:07 UTC |