@retval is not returning $itm, it returns nothing at all...
I wonder why??
#====================================================================
sub build_tree_for_cid($)
{
my ($cid) = @_;
print "The cid we are seeking:";
print "$cid\n";
my $item = new Item;
$item->id($cid);
$item->type(-1);
find_subs(\$item);
return $item;
}
#====================================================================
sub find_subs(\$)
{
my ($item) = @_;
print Dumper $$item;
my $SQL;
if ($$item->type == -1)
{
my $id = $$item->id;
print "printing the item id\n";
print "$id\n";
$SQL = qq[SELECT uc.puid, up.prod_id FROM users_customers uc,
user_products up
WHERE ((uc.puid = up.puid) AND (uc.cid = $id)
AND (up.from_date < SYSDATE)
AND (up.to_date IS NULL OR up.to_date > SYSDATE))];
}
else
{
my $id = $$item->id;
print "printing the item id\n";
print "$id\n";
$SQL = qq[SELECT u.puid, up.prod_id FROM users u, user_products u
+p
WHERE ((u.puid = up.puid) AND (u.parent_puid = $id)
AND (up.from_date < SYSDATE)
AND (up.to_date IS NULL OR up.to_date > SYSDATE))];
}
${$item}->subs(my_execer($SQL));
print Dumper $$item;
foreach my $subitem ($$item->subs)
{
find_subs(\$subitem);
}
return $item;
}
#====================================================================
sub my_execer($)
{
my ($sql) = @_;
print "$sql\n";
my $sth = $dbh->prepare($sql) || undef;
$sth->execute() || die "sth->execute: $DBI::errstr";
my @row;
my @retval;
if (@row = $sth->fetchrow_array)
{
my ($puid, $prod_id) = @row;
print "printing weird stuff\n";
print "$puid\n";
print "$prod_id\n";
my $itm = new Item;
$itm->id($puid);
$itm->type($prod_id);
print Dumper $itm;
push (@retval,$itm);
}
$sth->finish;
print "\@retval contains $#retval \n";
return (@retval);
}
#====================================================================
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, 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, 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.
|
|