Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Error trapping for referential-integrity triggers
Message
 
 
À
02/03/2006 14:24:24
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 6
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01101036
Message ID:
01101039
Vues:
11
>Hi all,
>
>In bringing our old FPD 2.5 system into VFP 6, I decided to take advantage of the Referential Integrity features. I understand the concept, but am having some trouble putting it into actual use.
>
>For example, I've got the following two tables:
>
>customer (parent)
>orders (child)
>
>One-to-many relationship (obviously) as one customer can have many orders.
>
>I set it up so that if someone tries to delete (for example) customer #200, that will be prevented if there are any orders out there for customer #200 (rules for deleting = restrict).
>
>Now, when I go into my system and try to delete customer #200, I'd like the system to tell the user something like, "Customer #200 cannot be deleted as they have open orders." Instead, I just get a message that says "Trigger failed," and the thing crashes.
>
>I'm assuming there's gotta be somewhere to put code to handle a failed trigger, but where?
>
>Thanks very much!
>
>John

Looks like there is no way to substitute this message with the custom message on the table level. Therefore you should code accordingly in your Data-Tier Error method.

In The MereMortals framework there is a method in cCursor GetTriggerErrorMsg():
LOCAL laError[AERROR_NUMCOLUMNS], laTriggerMessages[3], lcMessage

=AERROR(laError)

*--------------------------------------------------
*-- Transfer custom messages to the local array
*--------------------------------------------------
laTriggerMessages[TRIGGER_INSERT] = MsgSvc("((TEXT))InsertTriggerMsg")
laTriggerMessages[TRIGGER_UPDATE] = MsgSvc("((TEXT))UpdateTriggerMsg")
laTriggerMessages[TRIGGER_DELETE] = MsgSvc("((TEXT))DeleteTriggerMsg")

lcMessage = laTriggerMessages[laError[AERROR_TRIGGER]]

RETURN lcMessage
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform