MySQL Forums
Forum List  »  Perl

executing an SQL statement
Posted by: Lois Kim
Date: April 10, 2007 04:15PM

Hi!

I have a sql statment stored in a .sql file and I'd like to execute the statment of the file from my perl script. This file is to generate a text file using SELECT ... INTO OUTFILE...with the file name, displaying the date it is generated.
It runs fine if I execute the file from the MySQL command line using SOURCE and the path, but it does not run if I include the SQL statement in my perl script, using '$dbh->prepare' or '$dbh->do' as follows:
(I am working on Windows and using MySQL & DBI stored in a library.)

sub payfile
{
my $dbh;
my $sth;
my $stmt;

WebDB::connect ();

$sth = $dbh->prepare(CONCAT("SELECT Caseid, Updtname, Updtaddr, Updtcsz, Payto, Chkname, Chkaddr, Chkcsz
INTO OUTFILE '", DATE_FORMAT( NOW(), '%Y%m%d'), "SS.txt'", "
FIELDS TERMINATED BY ''
LINES TERMINATED BY '\r\n'
FROM miha2005.miha05
WHERE (Outcome=1 OR Outcome=2) AND Saqlang=3 AND Paid<>1 AND Payto<3"));
$sth->execute ();
$sth->finish ();
$dbh->disconnect ();
}
*************
If anybody can help me, I'd really appreciate it!

Options: ReplyQuote


Subject
Written By
Posted
executing an SQL statement
April 10, 2007 04:15PM
April 11, 2007 10:02AM
April 11, 2007 03:56PM
April 11, 2007 10:08AM
April 13, 2007 12:26PM
April 17, 2007 04:26PM
April 18, 2007 12:30PM
April 18, 2007 04:02PM
April 23, 2007 04:08PM
April 24, 2007 09:20AM
April 24, 2007 11:39AM
April 24, 2007 02:26PM
April 24, 2007 02:20PM
April 24, 2007 02:31PM
April 24, 2007 03:57PM
April 25, 2007 11:46PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.