http://www.perlmonks.org?node_id=1090204


in reply to Re^2: DBD::CSV::st execute failed. No such file or directory at C:/Perl64/lib/DBD/File.pm line 565
in thread DBD::CSV::st execute failed. No such file or directory at C:/Perl64/lib/DBD/File.pm line 565

Because you have SELECT * .. the column names in the hash are probably lower case. You can add a print join " ", keys %$row line to check this. To fix it I would define the column names in the SELECT and use fetchrow_array like this
#!perl use warnings; use strict; use DBI; my @col = qw(RECORD SUBSCRIPT ID_SUBSTN CO_SUBSTN AREA_SUBSTN ID_DEVTYP ID_DEVICE NAME_DEVICE AREA_DEVICE ID_MEAS ID_POINT SITE_POINT AREA_POINT); my $cols = join ",",@col; # Create connection string to database point.csv my $dbh = DBI->connect ("dbi:CSV:", undef, undef, { f_ext => ".csv/r", f_encoding => "utf-8", }); my $sth = $dbh->prepare ("SELECT $cols FROM point WHERE ID_DEVTYP LIKE 'INTELI%' AND ID_POINT LIKE 'AUTO%'"); $sth->execute; # Create AFS CSV with Columns open DAT_OUTPUT,'>','AFS.csv' or die "Could not open AFS.csv : $!"; print DAT_OUTPUT $cols."\n"; # Cycle through SQL results on ROW basis and print to AFS CSV file while (my @row = $sth->fetchrow_array) { print DAT_OUTPUT (join ",",@row)."\n"; } # Close file close DAT_OUTPUT;
poj
  • Comment on Re^3: DBD::CSV::st execute failed. No such file or directory at C:/Perl64/lib/DBD/File.pm line 565
  • Select or Download Code

Replies are listed 'Best First'.
Re^4: DBD::CSV::st execute failed. No such file or directory at C:/Perl64/lib/DBD/File.pm line 565
by PrincessofPERL (Initiate) on Jun 18, 2014 at 03:38 UTC
    Thank you for your response. Here is a Challenge Your code works in v5.10.1 Binary build 1007 291969 but not Binary build 1006 291086 My former code worked in Build 1006 but not 1007. point.csv does exist.. in the same directory Here is my error message.. still peculiar to a file open issue. The File.pm is ~2009 on the 1007 build and ~2008 on the 1006 build.
    C:\....>afs_filter.pl Execution ERROR: Cannot open point: No such file or directory at C:/P +erl64/lib/DBD/File.pm line 579. . DBD::CSV::st fetchrow_array failed: Attempt to fetch row without a pre +ceeding execute() call or from a non-SELECT statement [for Statement +"SELECT RECORD,SUBSCRIPT,ID_SUBSTN,CO_SUBSTN,AREA_SUBSTN,ID_D EVTYP,ID_DEVICE,NAME_DEVICE,AREA_DEVICE,ID_MEAS,ID_POINT,SITE_POINT,AR +EA_POINT FROM point WHERE ID_DEVTYP LIKE 'INTELI%' AND ID_POINT LIKE + 'AUTO%'"] at C:\....afs_filter.pl line 53.
    Any ideas? Thanks
      It is extremely rare that the "binary build" matters ; Its the module versions that matter; upgrade; see what you use with Devel::VersionDump