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

I'm sure it's something I'm doing since I'm a novice, but here's what's happening:
CODE:
#!/usr/bin/perl -w use strict; use Spreadsheet::WriteExcel; use DBI; my $dbh = DBI->connect('dbi:Oracle:fds','username','password') or print "ain't connecting"; my $test_query = "select category ,nvl(count,0) from ( select severity,count(1) count from fsc_rpt_vw where arrival_time >= trunc(sysdate-7) and assigned_to_group = 'CERES_FEDERATED' group by severity) a right outer join (select * from fsc_categories where type = 'SEV') b on b.category = a.severity order by category"; print "\n$test_query\n\n"; my $sth = $dbh->prepare($test_query); $sth->execute; #$cell = 63; my @results; while (@results=$sth->fetchrow_array) { print "category = $results[0]\n"; print "tkt_count = $results[1]\n"; print "results = @results\n\n"; }

RESULTS FROM CODE:
select category ,nvl(count,0) from (
select severity,count(1) count from fsc_rpt_vw
where arrival_time >= trunc(sysdate-7)
and assigned_to_group = 'CERES_FEDERATED'
group by severity) a right outer join
(select * from fsc_categories
where type = 'SEV') b on b.category = a.severity
order by category

category = 1
tkt_count = 0
results = 1 0

category = 2
tkt_count = 11
results = 2 11

category = 4
tkt_count = 7
results = 4 7


RESULTS FROM QUERY RAN IN TOAD:
query used is the exact query printed when the code is
executed

CATEGORY NVL(COUNT,0) 1 0 2 11 3 15 4 7

For the life of me, I can't figure out why it skipping the
record for category 3, but like I said, I'm reasonably
new to Perl. I did have a friend who has a lot more
experience, and together, we couldn't get it.


Thanks,
Kevin

Replies are listed 'Best First'.
Re: While loop seems to miss data
by Fletch (Bishop) on Apr 10, 2006 at 15:35 UTC

    $sth->trace( 2 ) might prove enlightening. Look for the section "TRACING" in the DBI perldocs for more details.