Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Updating a table based on a cursor
Message
From
14/01/2004 05:22:19
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00866620
Message ID:
00866630
Views:
16
>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

* Or
select result
scan
 update modacad set mochk009 = result.mochk009 ;
   where mainkey = result.mainkey
endscan
etc
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform