Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: DBD::CSV and fetchrow_hashref not working

by rnewsham (Curate)
on Dec 11, 2013 at 15:43 UTC ( #1066639=note: print w/replies, xml ) Need Help??

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"; }

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (1)
As of 2021-09-18 19:42 GMT
Find Nodes?
    Voting Booth?

    No recent polls found