Is it possible to Simplify 2 Selects, maybe into 1 as they add a bit of time when used in a Stored Procedure and called many times?
/* Get Our OVER Spent Codes */
select SUM(Cmt.BALANCE_TD)
from CODES_MONTHLY_TABLE Cmt
WHERE (Cmt.id = :ip_id) and (Cmt.BALANCE_TD < 0) and ((Cmt.THEMONTH - 1) = :ip_currentmonth)
into :op_overspent_codes;
/* Get Our UNDER Spent Codes */
select SUM(Cmt.BALANCE_TD)
from CODES_MONTHLY_TABLE Cmt
WHERE (Cmt.id = :ip_id) and (Cmt.BALANCE_TD > 0) and ((Cmt.THEMONTH - 1) = :ip_currentmonth)
into :op_underspent_codes;
The table CODES_MONTHLY_TABLE is quite large and I have an index on the field
Cmt.id.
These are input parameters:-
:ip_id
:ip_currentmonth
tia