Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What should I do if a DELETE fails?
Message
De
27/08/2006 12:14:43
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
27/08/2006 12:03:37
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP1
Network:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01148871
Message ID:
01148916
Vues:
16
>Hi
>
>I had the same idea too. The only difference is that I want to RECALL all the records that were deleted on the process. My biggest concern is how the user will have to deal with this unwanted data. Do you know how to reproduce a case like this?
>
>Regards

Once the records are deleted, you should consider them deleted, gone, disappeared. Normally you shouldn't give the user the option to recall a record deleted some days ago; this would cause too much trouble.

In this case, assuming you want to undo changes if something fails, you don't need to recall anything. Instead, you use transactions. Here is a typical example:
local llSuccess
use MyTable
CursorSetProp("Buffering", 5)
begin transaction
scan for (some condition)
  delete
  llSuccess = TableUpdate()
  if not llSuccess
    TableRevert()
    exit
  endif
endscan
if llSuccess
  end transaction && This will confirm all the changes
  MessageBox("Success")
else
  rollback && This will undo all the changes
  MessageBox("Some records could not be deleted. All changes were undone.")
endif
Note that with older versions of Visual FoxPro (including version 6), the transaction only works for tables in a database.
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)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform