Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Views - How do I update source tables?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00068429
Message ID:
00068507
Views:
26
>>>>OK, I'm a little new at this but I have created a view which uses three other tables to extract information that meets a particular criteria. Once I am satisfied with the data, I want to globally go back and change two fields in the source tables that serve as flags for each record in the view using the UPDATE command. I tried to construct one but keep getting a syntax error. I tried this
>>>>
>>>>UPDATE sourcetbl1 SET column3="0001"
>>>>WHERE viewtbl.column1=sourcetbl1.column1;
>>>>AND viewtbl.column2=sourcetbl1.column2
>>>
>>>At first glance, here are a couple of things...
>>>
>>>You have no semicolon at the end of your first line
>>>
>>>Since there is no space between "column1" and the semicolon, without a space before "AND" at the first line, VFP will interpret the line as:
>>>
>>>WHERE viewtbl.column1=sourcetbl1.column1AND viewtbl.column2=sourcetbl1.column2
>>>
>>>Christopher
>>
>>I see the problem and corrected the syntax, however when the command runs it only updates the first record in the sourcetbl that meets the condition. There are obviously many more matches. How do I get to them?
>
>Now you have a different problem. :)
>
>UPDATE - SQL works for single tables only. As such, it's only matching with the current value in your child table rather than performing a query like a select.
>
>IMHO, you're better off with a relation and a scan..endscan.
>
>(and this from someone who eats, sleeps, and breathes SQL) :)
>
>Christopher

The parenthetical means a lot to me. However, I am only trying to update a single source table, just many records in that table. Are you saying that the WHERE clause can not reference values in another table?
CySolutions, Medical Information Technology
You're only as good as your last
success, so . . .If it works. . .don't fix it!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform