Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What should I do if a DELETE fails?
Message
From
26/08/2006 23:26:22
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
26/08/2006 22:21:59
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP1
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01148871
Message ID:
01148876
Views:
13
>Hi!
>
>Let's say I want to delete multiple records from some buffered related tables, but the commands fails. What should I do in this case in order to avoid any unexpected problems in my app?

More or less the same as with any other modification. Here is an example of getting information, in a form. A single record is deleted.
delete
if TableUpdate()
  skip
  ThisForm.Refresh()
else
  local laError(1)
  aerror(laError)
  MessageBox("Error deleting. Error #" + transform(laError(1));
    + " Message " + laError(2))
endif
Now, what do you do when you delete several records, and it fails? You must decide what is appropriate for the logic of the application.

For instance, you can continue deleting all the records you can, and show the user a list of records that can't be deleted.

Another possibility is to delete "all or nothing" - if you can't delete one record, undo everything. This, you would do with transactions.
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