Home » SQL & PL/SQL » SQL & PL/SQL » variables in this loop procedure
variables in this loop procedure [message #443431] Mon, 15 February 2010 14:24 Go to next message
pyscho
Messages: 134
Registered: December 2009
Senior Member
    PROCEDURE CALCULATE_CASH_REBAL( P_Account_id    IN VARCHAR2,
                                    P_Txn_Ccy       IN VARCHAR2,
                                    P_Allocation    IN VARCHAR2,
                                    l_lty_id        IN VARCHAR2 ) IS
    
    l_balance_fmt       NUMBER := 0;
                          
    BEGIN
        

        FOR CASH_TXNS IN ( SELECT   * 
                           FROM     PF.PF_CASH_TXNS 
                           WHERE    ACCOUNT_ID  = P_Account_Id 
                           AND      TXN_CCY     = P_Txn_Ccy ) 
        
        LOOP            
       
            l_balance_fmt := l_balance_fmt + CASH_TXNS.AMT;
            
            -- update other fields like this too.
        END LOOP;
        
    END CALCULATE_CASH_REBAL;


it should be updating l_balance_fmt field for all the records in the loop. my question is when it loops to the next cash txn record, will it take the previous value of l_balance_fmt ? it should start again and take 0 as the balance_fmt and add to that..

i havent got data to test it yet, and thought id ask here and also to check if im doing it right
Re: variables in this loop procedure [message #443433 is a reply to message #443431] Mon, 15 February 2010 14:38 Go to previous messageGo to next message
BlackSwan
Messages: 25046
Registered: January 2009
Location: SoCal
Senior Member
> it should start again and take 0 as the balance_fmt and add to that..
When or under what conditions should BALANCE_FMT get reset to 0?
Re: variables in this loop procedure [message #443437 is a reply to message #443433] Mon, 15 February 2010 14:49 Go to previous messageGo to next message
pyscho
Messages: 134
Registered: December 2009
Senior Member
BlackSwan wrote on Mon, 15 February 2010 14:38
> it should start again and take 0 as the balance_fmt and add to that..
When or under what conditions should BALANCE_FMT get reset to 0?


After a CASH_TXNS entry has been processed in the loop
Re: variables in this loop procedure [message #443521 is a reply to message #443431] Tue, 16 February 2010 02:23 Go to previous message
cookiemonster
Messages: 12420
Registered: September 2008
Location: Rainy Manchester
Senior Member
Does that mean you want to reset it on each iteration of the loop?
Previous Topic: double recursion
Next Topic: How to read oracle diagram in the documentation?
Goto Forum:
  


Current Time: Thu Dec 08 06:24:21 CST 2016

Total time taken to generate the page: 0.13130 seconds