How I can i increase the perfomance of the follwoing procedure.
Please help me. IT is taking long time
I used BULK COLLECT to improve. it is executing in half time but experts says not good idea to update raws in not a good idea.
Expert say as under.
If you do update in chunks and the process fails, how do you know which customers have been given a rebate and which customers not? How do you restart this business transaction that you chose to implements as multiple database transactions?
What happens during the time of these serial batch chunk runs when new customers are added? Or existing customers are deleted (and the rebate already subtracted from the company's coffers are deleted with it)?
The problem here is not locking. Or concurrency. The problem is plain and simple - a damn poor and very flawed database design. Why?
For debiting and crediting you use a TRANSACTION table. You do not directly updates the balances of customers. You insert rows as debits and credits against a customer account.
Any Suggestion please
Please help me. IT is taking long time
I used BULK COLLECT to improve. it is executing in half time but experts says not good idea to update raws in not a good idea.
Expert say as under.
If you do update in chunks and the process fails, how do you know which customers have been given a rebate and which customers not? How do you restart this business transaction that you chose to implements as multiple database transactions?
What happens during the time of these serial batch chunk runs when new customers are added? Or existing customers are deleted (and the rebate already subtracted from the company's coffers are deleted with it)?
The problem here is not locking. Or concurrency. The problem is plain and simple - a damn poor and very flawed database design. Why?
For debiting and crediting you use a TRANSACTION table. You do not directly updates the balances of customers. You insert rows as debits and credits against a customer account.
Any Suggestion please
Code:
PROCEDURE SP_930_End_Of_Week_OH_up (
pSKU In
SS_SKU_Store_Week.SKU%Type,
pStore In
SS_SKU_Store_Week.Store_Num%Type) Is
DECLARE
Cursor OpportunityRating_Cursor Is
SELECT /*+ index (SS_SKU_Store_Week
SS_SKU_STR_WK_PK )*/ Opportunity_Rating,
End_Of_Week_On_Hand,
Decode(PSW_Flag, 0, 0,
Distributed_Planned_Sales)
DistributedPlannedSales
FROM SS_SKU_Store_Week
WHERE SKU = pSKU AND
Store_Num = pStore
ORDER BY Year_Week_Key Desc FOR UPDATE;
BEGIN
vForwardSales := 0;
For rWeek In OpportunityRating_Cursor Loop
If rWeek.Opportunity_Rating Is Not Null Then
UPDATE SS_SKU_Store_Week
SET Opportunity_Rating = Decode
(vForwardSales, 0, 1, Round
reek.End_Of_Week_On_Hand / vForwardSales, 4))
WHERE CURRENT OF OpportunityRating_Cursor;
vForwardSales := 0;
End If;
vForwardSales := vForwardSales +
rWeek.DistributedPlannedSales;
End Loop;
Commit;
Exception
When OTHERS Then
Null;
END;