http://qs321.pair.com?node_id=1066639


in reply to DBD::CSV and fetchrow_hashref not working

I am not sure about your connect method, I think that might be the source of your problem. It could be something to do with the escaping of your separation character when providing the arguments in that format.

Here is a modified version of your code which seems to do what you want.

use strict; use warnings; use DBI; use Data::Dumper; my $dbh = DBI->connect("DBI:CSV:", undef, undef, { csv_eol=> "\r\n", c +sv_sep_char => '~'}); $dbh->{'csv_tables'}->{'JPDObj'} = {'file' => 'data/objectives-cqdc.tx +t','col_names' => ["Obj","PosNbr","Year","Div","AVP","Dept","SDescr", +"Major","Methods","Results","Accompl","JanUp","LDescr","Changes","Cha +rs","Goals","Budget","CFObj"]}; $dbh->{'RaiseError'} = 1; $@ = ''; my $Cposition = '00001576'; my $Cyear = 2014; my $results = $dbh->selectall_arrayref( "SELECT Obj,SDescr,Major,Year, +LDescr FROM JPDObj WHERE PosNbr = ? AND Year = ?", { Slice => {} }, $ +Cposition, $Cyear); for ( @$results ) { print Dumper( $_ ) . "\n"; }