Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2020-11-24 21:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?