i'm using dbi to connect to an oracle database
i have a partitioned table and am looping thru this partition name list.
from this list i want to select the data and insert it into a table so i
have this code
for ( $xx=0;$xx<$v_cnt;$xx++)
{[
$prtsql= $dbh->prepare(
"insert into mth_nft
(accountid
, transactioncategory
, price
, starttime)
(select
accountid
,transactioncategory
,price
,starttime
from owner.transaction partition (@plist[$xx])
where
transactioncategory in (2,3,5,6)
and starttime between
p_dates.month_begin(sysdate,-$nummnths)
and p_dates.month_end(sysdate,-$nummnths)
and accountid = 1406240)");
$pigmonkey = $prtsql->execute or die "Error";
print "WOW, $pigmonkey\n";
$prtsql->bind_columns(undef, \$acct, \$transc, \$price, \$startt);
while ( $prtsql->fetch() ) {
print "$acct $transc $price $startt\n";
}
$dbh->commit;
}
when i try to run it there are sometimes no data returned from the select
statement so i get this error
Statement has no result columns to bind (perhaps you need to successfully
call execute first) at ./partfind line 134.
i'm guessing i'm not doing the insert quite right. i know the actual sql
code is correct so my question is how do i write this correctly, and, if
the select part of the query returns no rows, i just want the loop to
continue.
thanks.
r