Skip to Content.
Sympa Menu

freetds - Re: 4.2 limitation...

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Tom Samplonius <tom AT sdf.com>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: Re: 4.2 limitation...
  • Date: Tue, 2 Jan 2001 10:52:56 -0800 (PST)



On Tue, 2 Jan 2001, mjn wrote:

> $state="ca";
> my $sth = $dbh->prepare('SELECT * FROM authors WHERE state = $state');
>
> All of the variable syntax itterations that I know have failed...

As has been mentioned, single quoted strings are not expanded. That is
just the way Perl works.

Plus, you aren't quoting the string. It must be a valid SQL statement,
and SQL strings must be quoted:

$state="ca";
my $sth = $dbh->prepare("SELECT * FROM authors WHERE state = \"$state\"");


BTW, using "*" in SELECT is never a good idea. If colums are added, or
moved about, you must rewrite your code. An explicit column list is
always best.

Tom





Archive powered by MHonArc 2.6.24.

Top of Page