MelaOS has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use Win32::ODBC; use Win32::OLE; #i call this to open the connection sub OpenMTPDB { my $Pwd = 'W*+h0rW/oU;'; if ($Connection_Type eq 'P'){ # Server=pgssqlea01; Database=MTPDB unless($db = new Win32::ODBC("dsn=MTPDB_P; UID=EAutoma +tion; PWD=$Pwd")){ print "DB Connection Error: " . Win32::ODBC::E +rror() . "\n"; exit; } } elsif ($Connection_Type eq 'D'){ # Server=pgssqlea01; Database=MTPDB unless($db = new Win32::ODBC("dsn=MTPDB_D; UID=EAutoma +tion; PWD=$Pwd")){ print "DB Connection Error: " . Win32::ODBC::E +rror() . "\n"; exit; } } return $db; } # my main part of the code #Get the FK_lot id $sql = "SELECT TOP 1 IDX FROM ECAST_LOT ORDER BY IDX DESC "; ## Only get the id once for one summary if ($id eq ""){ print "GOTI IN\n"; if ($db->Sql($sql)){ print "Error executing the sql: $sql\n"; $isSqlFailed = 1; last; } else{ my %temp; while($db->FetchRow()){ %temp = $db->DataHash(); $id = $temp{IDX}; } print "ID: $id\n\n"; } #end if db->Sql } $id++; #Insert data into the Ecast_Lot table $sql = <<SQL_USAGE; INSERT INTO ECAST_LOT(LOT,OPERATION,SUMMARY,DEVREV +STEP,DATETIME,TIU,TEST_PROGRAM,[TRIGGER],TOTAL_TESTED,TESTER_ID,HANDL +ER_ID,COLOR) values('$lot','$oper','$sum','$dev','$date','$tiu' +,'$tp','$trigger','$ttested','$tester','$handler','$color') SQL_USAGE print "SQL: $sql\n"; if ($db->Sql($sql)){ print "Error executing the sql: $sql\n"; $isSqlFailed = 1; last; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: ActivePerl sql connection~PLEASE HELP!!
by runrig (Abbot) on Aug 25, 2007 at 16:30 UTC | |
|
Re: ActivePerl sql connection~PLEASE HELP!!
by SFLEX (Chaplain) on Aug 25, 2007 at 12:38 UTC | |
|
Re: ActivePerl sql connection~PLEASE HELP!!
by SFLEX (Chaplain) on Aug 25, 2007 at 13:08 UTC |