Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Gurus, Can Fox Update views that are UNIONed???
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00653315
Message ID:
00653529
Views:
24
John,
Since you are only updating the one table, this should work. What is buffering set to for the underlying table? You could have a double buffering situation here. Once you TableUpdate() the view, the changes get written to the underlying table's buffer. If you don't TableUpdate() the table too, the changes are lost.

HTH.

>opps here is the view definition.
>* Gendetail and gendetailB are identical and each has unique idetailids
>
>OPEN DATABASE icams
>
>CREATE SQL VIEW v_test as ;
> select idetailid,cheaderid,cbasedon from gendetail ;
> where cheaderid = ?P_cheaderid;
> union all ;
> select idetailid,cheaderid ,cbasedon from gendetailb;
> where cheaderid = ?P_cheaderid
>
>DBSetProp('V_test', 'View', 'UpdateType', 1)
>DBSetProp('V_test', 'View', 'WhereType', 3)
>DBSetProp('V_test', 'View', 'FetchMemo', .T.)
>DBSetProp('V_test', 'View', 'SendUpdates', .T.)
>DBSetProp('V_test', 'View', 'Tables', 'icams_gendetail')
>
>
>
>
>DBSetProp('V_test.idetailid', 'Field', 'KeyField', .T.)
>DBSetProp('V_test.idetailid', 'Field', 'Updatable', .F.)
>DBSetProp('V_test.idetailid', 'Field', 'UpdateName', 'icams!gendetail.idetailid')
>DBSetProp('V_test.idetailid', 'Field', 'DataType', "I")
>
>DBSetProp('V_test.cbasedon', 'Field', 'KeyField', .F.)
>DBSetProp('V_test.cbasedon', 'Field', 'Updatable', .T.)
>DBSetProp('V_test.cbasedon', 'Field', 'UpdateName', 'icams!gendetail.cbasedon')
>DBSetProp('V_test.cbasedon', 'Field', 'DataType', "C")
>
>>>Can Fox Update views that are UNIONed???
>>>If so, how?
>>>
>>>Thanks!!!!
>>
>>It depends on a number of factors.
>>
>>1. Did you union queries from different tables or did you simply need two different filter expressions for the same table?
>>2. Did you concatenate the field lists of both tables (each field from both tables is unique in the result set) or did you use the same field names for different fields (table1.field1 and table2.field2 combine into resultset.field3)?
>>
>>Take the following example:
>>Table 1
>>Field1         Field2
>>1              John
>>2              Joe
>>3              Jim
>>
>>Table2
>>Field1         Field2
>>1              Baseball
>>2              Tennis
>>3              Croquet
>>
>>Result Set 1
>>select t1.field1, t1.field2, 0 as field3, space(8) as field4
>>   from table1 t1
>>union
>>select 0 as field1, space(8) as field2, t2.field1 as field3, t2.field2 as field4
>>   from table1 t2
>>
>>Field1       Field2         Field3         Field4
>>1            John           0
>>2            Joe            0
>>3            Jim            0
>>0                           1              Baseball
>>0                           2              Tennis
>>0                           3              Croquet
>>
>>Result Set 2
>>select t1.field1, t1.field2
>>   from table1 t1
>>union
>>select t2.field1, t2.field2
>>   from table1 t2
>>
>>Field1       Field2
>>1            John
>>2            Joe
>>3            Jim
>>1            Baseball
>>2            Tennis
>>3            Croquet
>>Changes in result set 1 can be sent to the backend. Field1 and Field3 would need to be configured as key values. Changes in result set 2 can not. There is no way of telliong which table each row comes from.
>>
>>If you post your union statement, a more definitive answer may be available.
>>
>>HTH.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform