Subject Looping SP
Author Roger Pullen
I have a stock control program where I need an SP
to move items from one location to another...
Stock for product in any one location is made
up from several transaction entries thus:

LOCATION DIVISION PROD_CODE UNIT_QTY
------------------------------------
5841 30832 18006 10
5841 30833 18006 10
5841 30807 18006 10
5841 30817 18006 10


I pass the SP parameters thus:

existing location (5841 in this case)
new location - say 5500
product code (18006)
qty to move - say 25


Conceptually I need to "loop" thru the
above result set moving the first 2 entries
by changing the location to 5500 (ie 20 total)
and splitting the third line into a balance
of 5 left and a new entry with the other 5 in
a new location - total 25 moved

I have been on this all day and feel am nearly
there but would appreciate a second opinion
as to the best approach

Regards


Roger P