in reply to Re: Quoting in DBI sql query for on the fly query
in thread Quoting in DBI sql query for on the fly query
#! perl -w use DBI; use DBD::ODBC; # open connection to Access database $dbh = DBI->connect('dbi:ODBC:fred3'); my @lines = <DATA>; my $line; foreach $line ( @lines ) { my $sqlstatement = q{ SELECT Table1.Name, Table1.Address, Table1.City +, Table1.State, Table1.ZIP, Table1.Phone FROM Table1 WHERE Table1.Bus +Type = ?}; my $sth = $dbh->prepare($sqlstatement); foreach my $line (<DATA>) { chomp $line; $sth->execute( $line ); my $newdir= 'c:\redone'; my $extension= ".txt"; my $target = "$newdir/$line"; open( FINAL, ">$target" ) or die "Can't open $target:$!"; #output database results while (@row=$sth->fetchrow_array) { print FINAL "$row[0]\n$row[1]\n$row[2] $row[3] $row[4]<br>\n$row[5]\n\ +n"} close FINAL; } # end of fetchrow_array } # end of loop for each of data below __DATA__ ARCHITECTS INVESTIGATORS
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Quoting in DBI sql query for on the fly query
by nedals (Deacon) on Oct 29, 2004 at 05:53 UTC | |
|
Re^3: Quoting in DBI sql query for on the fly query
by runrig (Abbot) on Oct 29, 2004 at 05:55 UTC | |
|
Re^3: Quoting in DBI sql query for on the fly query
by ryantate (Friar) on Oct 29, 2004 at 19:04 UTC |