Verifying a field

Last Post 14 Mar 2008 11:58 AM by Break40. 2 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Break40
New Member
New Member

--
21 Feb 2008 12:09 PM
I have a table that contains a running balance field. The records are added by the application program. Sometimes, this running balance is filled with the wrong number. I would like to have a routine that loops thorugh every record and if the balance is wrong, adds the correct number.

Is there an article or some other resource available to guide me.
Break40
New Member
New Member

--
14 Mar 2008 11:58 AM
In a nutshell the table I am working with continually has records added tracking transactions. As the new record is added the "runBalance" gets adjusted based on sales amount. Sometimes this fails and the balance is not correct. What I am looking to do is create the code in a stored procedure to loop through all records in a table and adjust the runbalance if needed. For example. The table would look like below.

Unique identifier for table is storeNo, SalesRepNo, tran_No

StoreNo salesRepNo Tran_No SalesAmt RunBalance
1 200 1 1000 1000
1 200 2 5000 6000
1 200 3 -2000 4000
2 200 4 3000 3000
2 200 5 4000 7000
2 200 6 -500 7500 (this record would be changed to 6500 and old record copied to log table

Break40
New Member
New Member

--
15 Mar 2008 06:55 AM
Sorry, I left out a very important note. All values are entered as positive, one other field "cat_code" determines if it is a positive or negative amount when computing balance. Can I use an If statement to do math? Cat_code=1 is positive, catcode 2 is negative.
You are not authorized to post a reply.

Acceptable Use Policy