Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Controling (at VFP) triggers's results of SQL Server
Message
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00305162
Message ID:
00305201
Views:
27
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform