Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Any suggestions will be greatly appreciated.#! c:\perl\bin\perl.exe -w # # InsertDrivers.pl #Importations and Declarations use Win32::ODBC; use DBI; my $DSN='Database'; my $field1='server'; my $field2='nic1_drv_version'; my ( $dbh, $sth1, $sth2, $vals, $driver, $servlist, $row, $sqlstatement1, $sqlstatement2, @row); #Open file for reading open(INPUT,"file.txt") || die; while (INPUT) { my ($servlist, $driver)=split(/,/); #Connect to database my $dbh=DBI->connect("dbi:ODBC:$DSN", "admin", "") or die "$DBI::e +rrstr\n"; $sqlstatement1=("SELECT server, nic1_drv_version FROM Servers"); $sth1=$dbh->prepare($sqlstatement1); $sth1->execute || die; @row=$sth1->fetchrow_array(); foreach ("$row\n" eq "$field1\n") { $sqlstatement2=("INSERT INTO Servers ($field2) VALUES ($dr +iver)"); $sth2=$dbh->prepare($sqlstatement2); $sth2->execute || die; } close (INPUT); $sth1->finish; $sth2->finish; $dbh->disconnect; }
2003-04-16 edit ybiC: replace square bracket chars with appropriate html entities, to eliminate unintended PM links
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Updating Specific Fields in MS Access
by pfaut (Priest) on Apr 17, 2003 at 01:40 UTC | |
by p0lp0t (Initiate) on Apr 17, 2003 at 21:29 UTC | |
by Enlil (Parson) on Apr 17, 2003 at 21:59 UTC | |
by p0lp0t (Initiate) on Apr 17, 2003 at 23:36 UTC | |
by pfaut (Priest) on Apr 18, 2003 at 00:24 UTC | |
| |
|
Re: Updating Specific Fields in MS Access
by Chmrr (Vicar) on Apr 17, 2003 at 01:29 UTC |