I get this error when I try to run this subroutine and I can't figure out why or how to fix it:
Code:
sub GetRowsOverThreshold
{
# This subroutine will check the SKU table to see if there are any rows that
# exceed the allowable threshold and have been flagged with DELETEME
my $threshold = shift;
my $sth = $global_dbh->prepare("SELECT /*+ index (s, sku2) */
l.P_PLANNERCODE
, s.loc
, COUNT(*)
FROM stsc.SKU s, stsc.LOC l
WHERE s.p_deleteme = 'DELETEME'
AND s.LOC = l.LOC
GROUP BY l.P_PLANNERCODE, s.LOC HAVING COUNT(*) >= ?") or die "Unable to prepare statement: $DBI::errstr";
my $numrows = $sth->execute($threshold) or die "Can't execute statement: $DBI::errstr";
$numrows = 0 if $numrows eq "0E0";
if ( $numrows > 0 )
{
my( $plannercode, $dealer, $count );
$sth->bind_columns( undef, \$plannercode, \$dealer, \$count );
LogMsg("Here are the dealers that have more than $threshold DELETEME's");
LogMsg("");
while( $sth->fetch() ) {
LogMsg("\t\t\t$plannercode, $dealer, $count");
push @output_array, [ $plannercode, $dealer, $count ]
}
LogMsg("");
# sort the array
@output_array = sort @output_array;
# check for problems which may have terminated the fetch early
die $sth->errstr if $sth->err;
$global_dbh->disconnect()
}
else
{
LogMsg("There are no records counts that exceed the threshold of $threshold");
}
}
Here's the exact error:
Code:
DBD::Oracle::st execute failed: ORA-01722: invalid number (DBD ERROR: error possibly near <*> indicator at char 386 in 'SELECT
l.P_PLANNERCODE
, s.loc
, COUNT(*)
FROM stsc.SKU s, stsc.LOC l
WHERE s.p_deleteme = 'DELETEME'
AND s.LOC = l.LOC
GROUP BY l.P_PLANNERCODE, s.LOC HAVING COUNT(*) >= :<*>p1') [for Statement "SELECT
l.P_PLANNERCODE
, s.loc
, COUNT(*)
FROM stsc.SKU s, stsc.LOC l
WHERE s.p_deleteme = 'DELETEME'
AND s.LOC = l.LOC
GROUP BY l.P_PLANNERCODE, s.LOC HAVING COUNT(*) >= ?" with ParamValues: :p1=DBI::db=HASH(0x2022435c)] at DeleteMeProcess.pl line 115.
Can't execute statement: ORA-01722: invalid number (DBD ERROR: error possibly near <*> indicator at char 386 in 'SELECT
l.P_PLANNERCODE
, s.loc
, COUNT(*)
FROM stsc.SKU s, stsc.LOC l
WHERE s.p_deleteme = 'DELETEME'
AND s.LOC = l.LOC
GROUP BY l.P_PLANNERCODE, s.LOC HAVING COUNT(*) >= :<*>p1') at DeleteMeProcess.pl line 115.