On Wed, 2002-05-01 at 03:05, Schelstraete Bart wrote: > HEllo ppl, > > I hava a problem with Perl:DBI, and I hope somebody can help me. > I'm using perl to get data from the AS/400 DB2 database. > (Perl:DBI)....but the data that I'm receiving is not that same as the > data on the database... > This is a part of my script: > > $q = $dbh->prepare("select * from QS36SPL.\"S.1.HAWB\""); > $q->execute; $i=0; > while ($r = $q->fetchrow_hashref) { > if ($i == 10) { > last; > } > print " $r->{HAHAWB}/ $r->{HAPCER} / $r->{HAWGT} / $r->{HAWGT} / > $r->{HAORIG} / $r->{HADEST} \n"; > $i++; > } > > $q->finish;
Please use a monospace font or tabs when sending email. > > > And this is the output: > > pvpuqyvupq/ 0 / 1.0 / 1.0 / BYd / bES > pvpuqyvupr/ 0 / 1.0 / 1.0 / BYd / bES > pvpuqyuusp/ 0 / 1.0 / 1.0 / BYd / bES > pvpuqyuusq/ 0 / 1.0 / 1.0 / BYd / bES > pupvqyuusp/ 0 / 1.0 / 1.0 / BYd / bES > > And those 'BYd' and 'BES' is not correct. In terms of output from the code snippet you presented this looks correct. What about the data is wrong? > When is use 'Data::Dumper', I'm only receiving '@@' as data........... How did you use Data::Dumper? I would replace the line that prints the results with this line: print Dumper($r); > > Somebody knows what the problem can be? > > > tnx, and best regards, > > Bart > > -- > Schelstraete Bart > DHL Aviation > [EMAIL PROTECTED] Finally you should be using the 'use strict;' and 'use warnings;' pragmas. I assume you aren't because $q, $i, and $r are never defined. In addition you may find a hash slice easier to work with rather than grabbing each hash entry by itself. I would rewrite this snippet like this: my $q = $dbh->prepare( qq{ select * from QS36SPL."S.1.HAWB" } ); $q->execute; my $i = 0; while (my $r = $q->fetchrow_hashref) { last if ($i++ == 10); { local $" = ' / '; print "@$r{ 'HAHAWB', 'HAPCER', 'HAWGT', 'HAWGT', 'HAORIG', 'HADEST' }\n"; } } $q->finish; -- Today is Sweetmorn the 48th day of Discord in the YOLD 3168 Umlaut Zebra über alles! Missile Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]