Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Views and deleted records
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00194164
Message ID:
00194627
Views:
16
>>>>
>>>>open data MyDataBase
>>>>set deleted off
>>>>create view testdel as select *,deleted() as Deleted from mytable
>>>>
>>>>modi view testdel
>>>>
>>>>I made it updateable, and set the where to key fields only. Make sure the deleted column isn't set as modifyable. Save the view Then...
>>>>
>>>>use MyTable
>>>>browse
>>>>
>>>>Mark a few rows deleted
>>>>
>>>>use
>>>>
>>>>now:
>>>>
>>>>use testdel
>>>>
>>>>Ok... this is where it gets tricky... the deleted field should be T for those records marked deleted... however, the records are not deleted in the view.
>>>>
>>>>So, you can't recall the record in the view and do table update. Code your system so that if someone presses the Undelete button you do the following code...
>>>>
>>>>recall for id=iCurrentRecordID in MyTable
>>>>requery()
>>>>
>>>>When I did this, the deleted field changed from T to F.
>>>>
>>>>Keep in mind... if the buffer is dirty you may want to do a tableupdate. Or, you might want to wait until the user presses save, then do your tableupdate, then do your recalls.
>>>>
>>>>I just tested it, and it does successfully tableupdate() changes made to the deleted records.
>>>>
>>>>HTH,
>>>>BOb
>>>
>>>OK Here is what I did wrong and the reason my records were not showing deleted as .T., my view is made up of several tables providing information to the view, with adnacmds as the one I am updating. So my statement had to be DELETED('adnacmds') AS deleted as I think the Select was not checking the adnacmds for being deleted at the time the select was run, if I used DELETED() AS deleted FoxPro was using one of the other tables in the view to test for deleted. Interesting... A little gotcha to be aware of.
>>
>>
>>The same applies to Views as for a normal SQL SELECT. You cannot use the DELETED() or RECNO() or any other functions that require an alias parameter when more than 1 table is involved. It's documented in the Help under SELECT -SQL.
>
>Thanks, that helps to know its documentented. I will pass this around to the other programmers.

You can get around it by doing a SELECT into a cursor for just the table your trying to determine the deleted status for (ie in a adnadeleted field), and then using that cursor in your other queries.
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Previous
Reply
Map
View

Click here to load this message in the networking platform