Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Controling (at VFP) triggers's results of SQL Server
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Divers
Thread ID:
00305162
Message ID:
00305201
Vues:
25
Ricardo,

If a rule within a trigger has been violated, you can return a status message to the client by using the TSQL RAISERROR command.

Expanding on your example:
CREATE TRIGGER TD_Customer ON customer FOR DELETE
AS
IF EXISTS (
  SELECT * 
  FROM orders INNER JOIN deleted
  ON orders.custid = deleted.custid)
  BEGIN
    RAISERROR('Customer has orders and cannot be removed', 11, 1)
    ROLLBACK
  END
The RAISERROR command will return the message back to the client with an error number of 50000. It's also possible to create your own error messages using the SEM or the sp_addmessage system stored procedure.

-Mike
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform