>I would like to update a table based on values within the cursor. Each record in the table has a field called 'mainkey' and the same in the cursor. I have a field namely mochk009 in the table and in the cursor. Therefore when I modify the cursor I then want to modify the table. My syntax is:
>
>
>SCAN
>replace modacad.mochk009 WITH result.mochk009 for result.mainkey=modacad.mainkey
>ENDSCAN
>
>
>I basically want to change modacad.mochk009 (table) with the value in the cursor (result) where the mainkey is both in modacad and result.
>
>Can anybody tell me what I am doing wrong?
>
>Many Thanks in advance.
Neil,
At first glance :
replace modacad.mochk009 WITH result.mochk009 for modacad.mainkey = result.mainkey in 'modacad'
However I haven't tested it and never used that way. If you have an index on mainky for result table :
select modacad
replace mochk009 with result.mochk009 for seek(Mainkey,'result','mainkey')
is a way.
select result
scan
if seek(MainKey,'modacad','mainkey')
replace mochk009 with result.mochk009 in 'modacad'
endif
endscan
select result
scan
update modacad set mochk009 = result.mochk009 ;
where mainkey = result.mainkey
endscan
etc
Cetin