how post-update trigger fire one time for multiple records
917815Feb 15 2012 — edited Feb 16 2012Hi,
I want to update one column at header block based on some calculation on detail block.
I am using Post-update trigger at detail block but its fire for each record so my update condition failed some time.
I want to fire it at one time. find the below code written in Post-update trigger
DECLARE
l_req_amt NUMBER := 0;
BEGIN
SELECT SUM (REQUESTED_AMOUNT)
INTO l_req_amt
FROM XXNMC_PAYREQ_INV_TBL
WHERE pay_req_id = :XXNMC_PAY_REQ_TBL.PAY_REQ_ID AND SELECTION = 'YES';
IF l_req_amt <= 0
THEN
FND_MESSAGE.debug ('Payment Request Total Amount can not be Negative or zero in post update: ' || l_req_amt);
FND_MESSAGE.ERROR;
RAISE Form_Trigger_Failure;
ELSE
UPDATE XXNMC_PAY_REQ_TBL
SET amount = l_req_amt --:XXNMC_PAYREQ_INV_TBL.AMOUNT_SUM---l_req_amt
WHERE pay_req_id = :XXNMC_PAY_REQ_TBL.PAY_REQ_ID;
END IF;
EXCEPTION
WHEN OTHERS
THEN
FND_MESSAGE.debug ('You can not create payment request with negative or zero amount-exception');
FND_MESSAGE.ERROR;
RAISE Form_Trigger_Failure;
END;
If there is 15 record in detail block and i need to select 4 record then trigger fire 4 times and if first record is negative then my error condition become true and RAISE Form_Trigger_Failure;
i try to use :System.cursor_Record and :System.Last_Record = 'TRUE' but it not helpful in this case.
Please suggest.
Thanks in advance..
Regards
Manish