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

Re: DBD::CSV and fetchrow_hashref not working

by rnewsham (Curate)
on Dec 11, 2013 at 15:43 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-18 00:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found