Copy info from one row in a table to another row in the same

Posted by Admin on 22-Oct-2008 13:07

I am looking for a little bit of help. I am needing to copy data the matches certian info from one rom to another row that match different info. here is what I have so far

define var d-user as c no-undo.

define var d-user1 as c no-undo.

for each prod where

prod.whse = "a"

no-lock:

assign

d-user = prod.prod

d-user1 = prod.valuea

.

for each prod where

prod.prod = d-user

and prod.whse = "b"

exclusive-lock:

assign

prod.valuea = d-user1

end.

end.

But this does not work. Any ideas would be very helpfull.

All Replies

Posted by Tim Kuehn on 22-Oct-2008 13:14

DEFINE a new buffer prod-b for prod.

then do your second FOR EACH using prod-b, like so:

Posted by Admin on 22-Oct-2008 13:33

Works great. Thank you for the quick response.

Posted by Thomas Mercer-Hursh on 22-Oct-2008 13:49

One might note that one does actually need the variables to hold the values from the first buffer since that buffer is still available, i.e., prod-b.valuea = prod.valuea.

Posted by Tim Kuehn on 22-Oct-2008 14:14

true, but we don't know what he left out of his example, and he didn't ask for an optimized version.

Posted by Thomas Mercer-Hursh on 22-Oct-2008 14:23

And the solution obviously worked ... I was just trying to extend the educational experience a bit!

This thread is closed