Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error executing: Query was empty

Status
Not open for further replies.

andrewxie

Programmer
May 29, 2003
15
US
expert,
I run a perl script on solaris9.
this is the script:
my $sql = "SELECT produce_code, product_name INTO OUTFILE 'export.txt' from products";
my $sth = $dbh->prepare($sth);
$sth->execute or die("Error executing:$DBI::errstr");

it returns error excuting: Query was empty at line 222.
when I run it at mysql>SELECT produce_code, product_name INTO OUTFILE 'export.txt' from products;
it returns records.

anybody can tell me what's wrong?

 
you are not doing 'use strict' are you! BAD Andrew! :)

look at this line
my $sth = $dbh->prepare($sth);

I think you meant to write
my $sth = $dbh->prepare($sql);

ALWAYS USE STRICT!! And it won't let you shoot yourself in the foot by doing this
 
thank you for your reply. but nothgin wrong with
my $sth = $dbh->prepare($sth); I used USE strict; the sytax is correct.
 
my $sql = "SELECT produce_code, product_name INTO OUTFILE 'export.txt' from products";
my $sth = $dbh->prepare($sth);
/|\
|
|

you are preparing $sth. You should be preparing $sql.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top