Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Meaningful error messages with referential integrity
Message
De
30/10/1997 17:35:17
 
 
À
30/10/1997 17:21:45
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Divers
Thread ID:
00057494
Message ID:
00057502
Vues:
36
>>This should be something simple...
>>
>>I have setup referential integrity with the RI builder....
>>but how do I make meaningful error messages appear instead
>>of the standard:
>>
>> Failed to update table: Trigger Failed
>>
>>Thanks in advance,
>>
>>Tony
>
>Have a look at the code that the RI builder generated (rierror). YOu can use the gaerrors array to tell what happened and why the trigger failed, and build your own error messagebox depending on which trigger failed. Basically you are modifying the RI's built in error handler. Make a copy of your custom code, however, because the next time you re-generate RI code, it will probablt write over it.

Reading my own message, it looks a little misleading...
You don't HAVE to modify the RI error code unless you want something out of the ordinary...
the global gaError array will probably provide all of the information you need. If you use table buffering the best place to capture this is right after the tableupdate. Something like this...

IF .NOT. TABLEUPDATE(.T.,.T.)
=TABLEREVERT(.T.) &&Revert the change
IF TYPE('gaErrors[1,1]') <> 'L'
=MESSAGEBOX(gaErrors[1,2] + chr(13) + 'This record has child records. Cannot delete.',0,;
"Trigger Failed")
ENDIF
Erik Moore
Clientelligence
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform