Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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

by PrincessofPERL (Initiate)
on Jun 17, 2014 at 18:58 UTC ( #1090191=note: print w/ replies, xml ) Need Help??


in reply to Re: 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

Forgot to reply with the versions

DBD::CSV 0.26 DBD::ODBC 1.23 DBD::SQLite 1.29 DBI 1.609
These are *constraints*


Comment on Re^2: DBD::CSV::st execute failed. No such file or directory at C:/Perl64/lib/DBD/File.pm line 565
Download Code
Re^3: DBD::CSV::st execute failed. No such file or directory at C:/Perl64/lib/DBD/File.pm line 565
by Anonymous Monk on Jun 18, 2014 at 03:46 UTC

      Greetings! Once again Thank you for your detailed replies and guidance. I have had some challenges with my PERL project. My code solution had to work with PERL v5.10.1 Build 1006, and another with Build 1007 (at the time I had no idea IT installed a different Build version on server #2). I had developed, tested, and validated on my project on Build 1006. It was to my surprise that the Build 1006 solution I made did not work on a server running Build 1007. The error message was the following:

      DBD::CSV::st execute failed: Execution ERROR: Cannot open afs: No such file or directory at C:/Perl +64/lib/DBD/File.pm line 565

      That message first appeared on the 2007 Build but NOT 2006 when I used this original code for my solution:

      # Create connection string to database point.csv (output file from sca +daexport.pl) my $dbh = DBI->connect ("dbi:CSV:csv_auto_diag=1", { f_dir => ".", f_ext => ".csv/r", f_enc => "utf-8", file => "point.csv", }); # Associate our csv file with the table name "AFS" and include custom +column names $dbh->{csv_tables}->{AFS} = { file => "point.csv", col_names => [qw( RECORD SUBSCRIPT ID_SUBSTN CO_SUBSTN AREA_SUBS +TN ID_DEVTYP ID_DEVICE NAME_DEVICE AREA_DEVICE ID_MEAS ID_POINT SITE_ +POINT AREA_POINT )], }; # Define and Execute SQL to select INTELI and AUTO points my $sth = $dbh->prepare ("select * from AFS where ID_DEVTYP like 'INTE +LI%' AND ID_POINT like 'AUTO%'"); $sth->execute;

      After your advice I had found a solution to my delight that worked on the 1007 build. But that self-esteem was very short lived when I discovered to my surprise that code did not work on the older 1006 build. Here is that code reference that I changed and worked on Build 1007 but lost compatibility with Build 1006

      my @col = qw(RECORD SUBSCRIPT ID_SUBSTN CO_SUBSTN AREA_SUBSTN ID_DEVTY +P 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;

      So I was stuck with two solutions. One set of scripts that worked with Build 1006, and one set that worked with Build 1007. I think it has been a bit of luck, following some of your suggestions, and experimentation that I have reached a happy medium that works with two different versions of the File.pm module from build 1006 to 1007. This is how I tricked File.pm on both Build 1006 and 1007 to accept my file. May not be pretty.. but it works.

      my @col = qw(RECORD SUBSCRIPT ID_SUBSTN CO_SUBSTN AREA_SUBSTN ID_DEVTY +P 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 (output file from sca +daexport.pl) my $dbh = DBI->connect ("dbi:CSV:", undef, undef, { f_encoding => "utf-8", }); # Define and Execute SQL to select INTELI and AUTO points my $sth = $dbh->prepare ("select $cols from point.csv where ID_DEVTYP +like 'INTELI%' AND ID_POINT like 'AUTO%'"); $sth->execute;

      and my hash solution now works with this. Here is the entire solution

      use warnings; use strict; use DBI; my @col = qw(RECORD SUBSCRIPT ID_SUBSTN CO_SUBSTN AREA_SUBSTN ID_DEVTY +P 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 (output file from sca +daexport.pl) my $dbh = DBI->connect ("dbi:CSV:", undef, undef, { f_encoding => "utf-8", }); # Define and Execute SQL to select INTELI and AUTO points my $sth = $dbh->prepare ("select $cols from point.csv where ID_DEVTYP +like 'INTELI%' AND ID_POINT like 'AUTO%'"); $sth->execute; # Create AFS CSV with Columns open (DAT_OUTPUT,">AFS.csv"); print DAT_OUTPUT "RECORD,SUBSCRIPT,ID_SUBSTN,CO_SUBSTN,AREA_SUBSTN,ID_ +DEVTYP,ID_DEVICE,NAME_DEVICE,AREA_DEVICE,ID_MEAS,ID_POINT,SITE_POINT, +AREA_POINT\n"; # Cycle through SQL results on ROW basis and print to AFS CSV file while (my $row = $sth->fetchrow_hashref) { print DAT_OUTPUT "$row->{RECORD},$row->{SUBSCRIPT},$row->{ID_SUB +STN},$row->{CO_SUBSTN},$row->{AREA_SUBSTN},$row->{ID_DEVTYP},$row->{I +D_DEVICE},$row->{NAME_DEVICE},$row->{AREA_DEVICE},$row->{ID_MEAS},$ro +w->{ID_POINT},$row->{SITE_POINT},$row->{AREA_POINT}\n"; } # Close file close DAT_OUTPUT;

      I've been recently told that my client has yet another server with perl 5.8.8 where this needs to run and they will not consider upgrading because of risk. I'm going to cross my fingers and do a shaman dance hoping this will work on an even older version of code. Cheers!

      And thank-you for your contributions to File.pm, I noticed your name in the file header.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1090191]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2014-12-29 01:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (184 votes), past polls