Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.58 KB | None | 0 0
  1. create procedure PozycjaFaktura
  2.     @id int, @id_faktura int, @id_alkohol int, @ilosc int
  3. as
  4. begin try
  5.     begin transaction
  6.     insert into Pozycja (ID,id_faktura,id_alkohol,ilosc) values (@id, @id_faktura, @id_alkohol, @ilosc)
  7.     declare @magazyn int
  8.     set @magazyn =(select a.ilosc from Alkohol a where a.ID =@id_alkohol)
  9.     if @ilosc>@magazyn
  10.         begin
  11.             raiserror('*** Wybrana ilosc przekracza dostępną w magazynie ***',16,1)
  12.         end
  13.     else
  14.         begin
  15.             update Alkohol set Alkohol.ilosc = @magazyn - @ilosc where Alkohol.ID=@id_alkohol;
  16.         end
  17.     commit
  18. end try
  19. begin catch
  20.     rollback
  21. end catch
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement