Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is UNION acceptable in a View?
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00485727
Message ID:
00486830
Views:
10
Hi!

Its just depended on how you build this view and data, logically.
When you modify data using view, you define keys - fields that will be used to identify record in the database. If you organize correct record identity, not a problem than to set properties of view before update to any table you want and send update. Of course, update cannot occur if table have bad structure, recrd is not unique etc etc. Anyway, all this possible. Its very wrong opinion that SQL SELECT statement of view defines all other behavior and properties, thus UNION-like queries cannot be updatable. VFP just cannot handle such queries in a generic way and set all other properties required for updates properly, VFP view designer even canot edit UNIOON-like queries. Programmatically you can use ANY query and update data using it. Programmers that work with SPT cursot oftemly and prganize automatic updates to the server using properties of the cursor can prove that.

>If the UNION is not a UNION ALL, a single record in the result could represent records in both source tables. If the record is changed in the view, does it do the same update in both tables, or what?
>
>>Hi!
>>
>>You're not correct. Any view and SPT cursor could be made updatable. There are 5 properties of cursor you can set to organize any king of update for any cursor. The query used to make cursor does not matters. Well, you cannot do this from the view designer, but definitely you can do this using CursorSetProp() and DBSetProp() functions.
>>
>>>>>It's legal to use UNIONs in a view, as long as it's defined with CREATE SQL VIEW and you don't later attempt to modify it with the VFP View Designer.
>>>>>
>>>>>However...
>>>>>
>>>>>Is it good practice to use UNION clause(s) in a view? Or, is that usually a sign that the database should be refactored?
>>>>
>>>>I think using UNION may be a (good) sign that the database is successuflly normalized. Usually views are used to denormalize data for particular uses, such as querying or reporting.
>>>
>>>Since a cursor from a UNION query will not be updateable, is there any reason to use a view rather than just a cursor? Might it add unnecessary overhead?
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Previous
Reply
Map
View

Click here to load this message in the networking platform