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;

In reply to last_insert_id issue by sowais

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.