List:General Discussion« Previous MessageNext Message »
From:Bruce Ferrell Date:May 13 2009 3:43pm
Subject:Select Into OUTFILE problem
View as plain text  
I have a bit of perl code that ends with an error:

$sql="SELECT convert_tz( a.stamp,'GMT','$tz' ) as ts, a.status,
             a.reason, a.tl
      INTO OUTFILE  '/application/result.csv'
      FIELDS TERMINATED BY ','
      ENCLOSED BY '\"'
      LINES TERMINATED BY '\n'
      FROM alerts a
      WHERE a.stamp BETWEEN ? AND ?
      ORDER BY a.stamp DESC";


 $sth = $dbh->prepare($sql);
 $rv = $sth->execute;

DBD::mysql::st execute failed: Can't create/write to file
'/application/result.csv' (Errcode: 2)

Te database is remote from the system where the perl is executing.

Te SQL works as expected when fed to mysql command line client
(i.e. mysql -h remote).  The outfile ends up in the application
directory of the macine running the mysql client.

What I'd found is, when the perl code runs the file tries to drop on the
database server and the application directory doesn't exist there giving
me the error.

Any suggestions to get the outfile to drop in the right place would be
appreciated.

Bruce
Thread
Select Into OUTFILE problemBruce Ferrell13 May
RE: Select Into OUTFILE problemGavin Towey15 May
  • Re: Select Into OUTFILE problemBruce Ferrell15 May