Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
RECALL with updateable views - bug?
Message
From
04/07/2003 18:04:41
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00807071
Message ID:
00807102
Views:
22
I think this is because the view internally generates standard SQL commands, commands that work both against DBF tables, and against a database server which will probably not even have the concept of deleted records.

For triggers and referential integrity, the situation is similar: when you RECALL a record, it is treated like a newly-inserted record. That is, the Insert Trigger gets executed. Quite logical, in this case.

I suggest you just treat deleted records as deleted. One benefit is that thus, your application is more scalable: you won't need to redesign for C/S.

Why exactly do you consider it a problem, or dangerous, if a new record is added, instead of re-using the old one?

>I was getting duplicate keys in an app using an updateable local view to update a free table. Yesterday I discovered that recalling a deleted record in a view DOES NOT RECALL the record in the base table, but actually creates a new record, a duplicate!!!
>
>Unless I missed something, this makes updateable views not only useless, but extremely dangerous.
>
>Here is code to reproduce the behavior:
>
>local lcDir, lnCnt
>
>close data all
>
>*lcDir='c:\fox\test1\test3'
>lcDir = 'c:\lvtest\'
>
>md (lcDir)
>
>set default to (lcDir)
>
>create table (lcDir)+'table1' free (id1 N(10), text1 C(10))
>for lnCnt = 1 to 5
>	insert into table1 (id1, text1) values (lnCnt, chr(lnCnt+64))
>endfor
>
>create database 'db1.dbc'
>create sql view "lv_table1" as select id1, text1 from  table1
>
>dbsetprop('lv_table1', 'View', 'UpdateType', 1)
>dbsetprop('lv_table1', 'View', 'WhereType', 3)
>dbsetprop('lv_table1', 'View', 'SendUpdates', .t.)
>DBSetProp('LV_TABLE1', 'View', 'Tables', 'table1')
>
>dbsetprop('lv_table1.id1', 'Field', 'KeyField', .t.)
>dbsetprop('lv_table1.id1', 'Field', 'Updatable', .t.)
>dbsetprop('lv_table1.id1', 'Field', 'UpdateName', 'table1.id1')
>
>dbsetprop('lv_table1.text1', 'Field', 'KeyField', .f.)
>dbsetprop('lv_table1.text1', 'Field', 'Updatable', .t.)
>dbsetprop('lv_table1.text1', 'Field', 'UpdateName', 'table1.text1')
>
>close data all
>
>select 0
>use table1
>browse last nowait
>
>select 0
>use db1!lv_table1
>browse last nowait
>
>delete
>?tableupdate(1,.t.,'lv_table1')
>recall
>?tableupdate(1,.t.,'lv_table1')
>
>
>Now if you click on the table1 browse window, you should see a duplicate record.
>
>I really hope I am missing something...
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform