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; my $hour = $timedata[2]; $hour = '0'.$hour if $hour <10; my $day = $timedata[3]; 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 = 'SMKAPP'; my $database_name = 'TESTDATA'; my $database_user = ''; my $database_pass = ''; my $env = 'SMOKE\\service-test'; my $partner = 'TEST'; my $msgid = '2013081107999999test'; my $DB_insert ='true'; my $filename = 'test_file'; my $line_count = 22; if($DB_insert =~ /true/i) { my $DSN = "driver={SQL Server};server=$server_name;database=$database_name;uid=$database_user;pwd=$database_pass;"; eval { my $dbh = DBI->connect("dbi:ODBC:$DSN"); DBI->trace(2,'C:\db_test_log3.txt'); my $sql = "INSERT INTO RecordCount VALUES (?,?,?,?,?,?)"; my $sth = $dbh->prepare($sql); $sth->bind_param(1, $env); $sth->bind_param(2, $partner); $sth->bind_param(3, $id); $sth->bind_param(4, $filename); $sth->bind_param(5, $temp_date); $sth->bind_param(6, $line_count); $sth->execute(); $dbh->disconnect(); }; if($@) { print "DB Failure: $@"; } } exit 0;