in reply to Re: Re: Updating Specific Fields in MS Access
in thread Updating Specific Fields in MS Access
So you need to put single quotes around $driver as it is not all numeric, nor the SQL keyword NULL, I have also changed you WHERE clause to reflect what I think you want it to do. One good resource for SQL syntax is w3schoolsmy $sqlstatement=("UPDATE servers SET nicl_driver_version = '$driver' +WHERE '$field1' = '$servlist'");
you also don't appear to be using $field2 or $vals for anything, and don't need the use Win32::ODBC; line for anything as well (you are not using that module in your code at all).
One last thing is that you might want to prepare your SQL statement outside your loop, and then execute it on the inside, so you don't have to prepare the same statement time and time again unnecessarily). So your code might look something like this(untested):
use DBI; use strict; my $DSN='Database'; my $field1 = 'Server'; my $dbh=DBI->connect("dbi:ODBC:$DSN", "admin", "") or die "$DBI::errstr\n"; my $sth = $dbh->prepare( "UPDATE Servers SET nic1_driver_version= ? WHERE '$field1' = ?" ); #Open file for reading open(INPUT,"file.txt") || die; while (<INPUT>) { chomp; my ($servlist, $driver)=split(/,/); $sth->execute($driver,$servlist) or die; } close (INPUT); $dbh->disconnect;
-enlil
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Updating Specific Fields in MS Access
by p0lp0t (Initiate) on Apr 17, 2003 at 23:36 UTC | |
by pfaut (Priest) on Apr 18, 2003 at 00:24 UTC | |
by p0lp0t (Initiate) on Apr 18, 2003 at 00:38 UTC |