sowais has asked for the wisdom of the Perl Monks concerning the following question:
Needd help figuring out why last_insert_id() is giving an error. I am using an INSERT statement via interpolating values (an issue asked in another post), but get "Inappropiate I/O control operation" on the last_insert_id line. I ran trace as well but didnt get much out of it.
Trace:
<- execute= ( 1 ) 1 items at C:\IMS_db.pl line 59 via at C:\IMS_db.pl line 43
-> last_insert_id for DBD::ODBC::db (DBI::db=HASH(0x2985304)~0x2985274 undef undef 'table' undef) thr#b52bac
<- last_insert_id= ( ) 0 items (not implemented) at C:\IMS_db.pl line 68 via at C:\IMS_db.pl line 43
<> DESTROY(DBI::st=HASH(0x2985534)) ignored for outer handle (inner DBI::st=HASH(0x29854f4) has ref cnt 1)
-> DESTROY for DBD::ODBC::st (DBI::st=HASH(0x29854f4)~INNER) thr#b52bac
<- DESTROY= ( undef ) 1 items at C:\IMS_db.pl line 43 via at C:\IMS_db.pl line 43
dbih_clearcom 0x29854f4 (com 0x27ffbe4, type 3) done.
use strict; use warnings; use DBI; use Time::HiRes qw/gettimeofday/; use Win32::ODBC; my @timedata = localtime(); my $sec = $timedata[0]; $sec = '0'.$sec if $sec < 10; my $min = $timedata[1]; $min = '0'.$min if $min < 10; #check I put in place for the single di +gits my $hour = $timedata[2]; $hour = '0'.$hour if $hour < 10; my $day = $timedata[3]; $day = '0'.$day if $day < 10; my $month = $timedata[4]+1; $month = '0'.$month if $month < 10; my $year = $timedata[5]+1900; (my $seconds, my $ms) = gettimeofday(); $ms = ($ms-($ms%1000))/1000; my $time = $hour.":".$min.":".$sec.".".$ms; my $date = $year."-".$month."-".$day; my $temp_date = $date.' '.$time; my $server_name = 'SMOKE-SERVER'; my $database_name = 'TESTDB'; my $database_user = ''; my $database_pass = ''; my $filename = 'test_file'; my $file_date = '2011-01-01 00:00:00.000'; my $record_count = 20; my $sheet_count = 400; my $doc_ID = 12; my $client_ID = 2; my $dbh; my $DSN = "driver={SQL Server};server=$server_name;database=$database_ +name;uid=$database_user;pwd=$database_pass;"; eval { $dbh = DBI->connect("dbi:ODBC:$DSN"); DBI->trace(4,'C:\db_test_log88.txt'); my $sql = "INSERT INTO table VALUES ('$filename','$file_date','$re +cord_count','$sheet_count','$doc_ID','$client_ID','$temp_date')"; my $sth = $dbh->prepare($sql); $sth->execute() or die "Execute Failed: $!"; my $last_ID = $dbh->last_insert_id(undef,undef,'table',undef) or d +ie "No Last ID: $!"; print "Last ID inserted: $last_ID"; $dbh->disconnect(); }; if($@) { print "DB Failure: $@"; } exit 0;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: last_insert_id issue
by fishmonger (Chaplain) on Aug 27, 2014 at 16:55 UTC | |
by sowais (Sexton) on Aug 27, 2014 at 17:20 UTC | |
by arkturuz (Curate) on Aug 27, 2014 at 18:12 UTC | |
Re: last_insert_id issue
by fishmonger (Chaplain) on Aug 27, 2014 at 17:01 UTC | |
by sowais (Sexton) on Aug 27, 2014 at 17:36 UTC | |
Re: last_insert_id issue
by ikegami (Patriarch) on Aug 27, 2014 at 19:13 UTC | |
by sowais (Sexton) on Aug 27, 2014 at 20:25 UTC | |
by ikegami (Patriarch) on Aug 27, 2014 at 21:35 UTC | |
by fishmonger (Chaplain) on Aug 27, 2014 at 20:38 UTC |