I am trying to create stored procedure which will insert one row in the first table and identity of inserted row in other two tables. For some reason I am receiving error "Procedure or function expects parameter '@id', which was not supplied.". My code is as follows:
ALTER PROCEDURE InsertProf
(
@id int output,
@added datetime2,
@addedby nvarchar(50),
@ime nvarchar(50),
@prezime nvarchar(50),
@fakultet int
)
AS
BEGIN
SET NOCOUNT ON;
declare @IdentityOutput table(ID int)
INSERT INTO np_Profesori
(Ime, Prezime)
output inserted.IDProfesor into @IdentityOutput
VALUES (@ime, @prezime)
SET @id=(select ID from @IdentityOutput)
INSERT INTO np_GdjeRadi
(IDProfesor, IDFakultet)
VALUES (@id, @fakultet)
INSERT INTO np_DodavanjeProfesora
(IDProfesor, Added, AddedBy)
VALUES (@id, @added, @addedby)
END
Thank you!