petermckeown has asked for the wisdom of the Perl Monks concerning the following question:

Hello
I'm trying to write a script in 5.6.0 using DBI 1.28 and DBD-Oracle 1.12 (oracle parallel server 8.1.7.0.0 on Compaq Tru64) and I can not get fetchrow_hashref working correctly (DBI and DBD installed OK no errors)

Below are two versions of the code (i want to use the top one! - it returns pages of blanks - the second version returns the details as expected!

while (my $data = $sth->fetchrow_hashref) { my $supplier = $data->{'supplier'}; print $supplier . "\n"; } #while (my @data = $sth->fetchrow_array) { # #my $supplier = $data->{'supplier'}; # my $supplier = $data[0]; # print $supplier . "\n"; #}
Thank you in advance
Pete

edited: Thu Jun 20 16:01:03 2002 by jeffa - added code tags, removed excessive br tags

Replies are listed 'Best First'.
Re: fetchrow_hashref returns blanks
by thunders (Priest) on Jun 20, 2002 at 16:00 UTC
    It's hard to say why this is happening from your code, which is using the correct syntax. Debug with the always useful Data::Dumper
    use Data::Dumper; while (my $data = $sth->fetchrow_hashref) { print Dumper($data); }
    Your hashref may not contain exactly what you think it does.
Re: fetchrow_hashref returns blanks
by ides (Deacon) on Jun 20, 2002 at 15:54 UTC
    I could be that DBD::Oracle does not support that portion of DBI. I've seen simliar things with DBI/DBD in the past. I searched through the DBD::Oracle documentation and found no mention of it not supporting this feature however.

    You might also want to note that fetchrow_array is faster than fetchrow_hashref. If you looking for speed it might be better to stay with what is working now, despite the increase in code complexity.

    -----------------------------------
    Frank Wiles <frank@wiles.org>
    http://frank.wiles.org

Re: fetchrow_hashref returns blanks
by Anonymous Monk on Jun 20, 2002 at 16:39 UTC
    Thank you very much - oracle was returning the column names in uppercase (as shown by Data::Dumper) You help is very much appreciated