Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Updating one table with data from another
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00490636
Message ID:
00491308
Views:
9
>>Hi Eric,
>> This is the code I have so far:
>>
>>
>>close table all
>>use student in 0
>>use xstud in 0
>>
>>select student
>>scan
>>    if seek(student.cstud_key,xstud)
>>        replace student.cstud_id with xstud.cstud_id
>>    endif
>>    select student
>>endscan
>>
>>
>>When I run it, the program errors out with "Variable 'xstud' is not found."
>>
>>
>>xstud is a table in my database. I defined a one-to-one relationship between student and xstud on cstud_key. Both tables have a primary cstud_key key and the cstud_id field. I am trying to update the student table with the value in the xstud table using a matching cstud_key.
>I'm sorry to butt in at this stage but it seems that we're making the simple complicated. Try this:
>
>close table all
>use student
>select 0
>use xstud order cstud_key
>select student
>set relation to cstud_key into xstud
>replace cstud_id with xstud.cstud_id for found('xstud')
>
>*** That's all there is to it (I'm assuming the index
>*** tag is named cstud_key

<g> There is always a better way. Actually this example I gave was an example of how I use scan for more flexibility.
Eric Kleeman - EDS Consulting Services
MCP Visual FoxPro
MCSD C#.NET
Hua Hin Thailand
Los Angeles California
Previous
Reply
Map
View

Click here to load this message in the networking platform