Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create procedure PozycjaFaktura
- @id int, @id_faktura int, @id_alkohol int, @ilosc int
- as
- begin try
- begin transaction
- insert into Pozycja (ID,id_faktura,id_alkohol,ilosc) values (@id, @id_faktura, @id_alkohol, @ilosc)
- declare @magazyn int
- set @magazyn =(select a.ilosc from Alkohol a where a.ID =@id_alkohol)
- if @ilosc>@magazyn
- begin
- raiserror('*** Wybrana ilosc przekracza dostΔpnΔ w magazynie ***',16,1)
- end
- else
- begin
- update Alkohol set Alkohol.ilosc = @magazyn - @ilosc where Alkohol.ID=@id_alkohol;
- end
- commit
- end try
- begin catch
- rollback
- end catch
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement