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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.