a guest Dec 13th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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;
  16.         end
  17.     commit
  18. end try
  19. begin catch
  20.     rollback
  21. end catch
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand