Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.43 KB | None | 0 0
  1. CREATE TRIGGER VerifierStock
  2. ON commandes
  3. FOR  INSERT
  4. AS
  5. BEGIN
  6.     declare @id_stock int,@quantite_commande int
  7.     select @id_stock = id_stock FROM INSERTED
  8.     select @quantite_commande = quantite_commande FROM INSERTED
  9.  
  10.     IF (SELECT quantite_stocke FROM stock WHERE id_stock = @id_stock) < @quantite_commande
  11.         BEGIN
  12.             RAISERROR('La quantité demandé n est pas disponible pour le stock',16,10)
  13.             Rollback transaction
  14.         END
  15.  
  16. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement