On Apr 13, 2004, at 6:21 PM, Mathew Robertson wrote:


I can get the results to print directly with this code:

$sth = $dbh->prepare ("SELECT * FROM $working_tbl WHERE first='one'
ORDER BY Location");
$sth->execute ();
while ( my $hash_ref = $sth->fetchrow_hashref ) {
        print "ID: $hash_ref->{'ID'} -- Name: $hash_ref->{'Name'}
(etc....) <br>\n";
}

this is cool, but do note that the DBI docs generally advise against the
use of a variable table name (well... I understand them to be advising
against) as it doesn't allow for creating a plan and optimizing the
query. Anyway...

What has Perl's string interpolation got to do with DBI?


"SELECT * FROM $working_tbl WHERE first='one' ORDER BY Location"

The variable $working_tbl will be interpolated by Perl, long before DBI ever gets to see the SQL statement, due to the double-quote.



you are correct, and my advise was half-baked. The assertion I made holds true when doing multiple queries using bind variables, and hence, I try to stay away from variable-izing table names... that is where my advise came from and it really doesn't apply to Carl's case. But, as they say... you gotta do what you gotta do.




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Html-template-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to