I wanna write a store procedure, which takes 4 parameters and one parameters must be entered, in order to find the right product to update it from the lager under different conditions. I do not know, where is my mistake. When i execute, i get such error The parameter '@productName' has been declared as NOT NULL. NOT NULL parameters are only supported with natively compiled modules, except for inline table-valued functions. I really appreciate your gently and kindly feedback to improve myself. I could not find the right answer online.
Here is my Code:
create procedure dbo.Update_Lager (@productName varchar (50) not null, @info varchar(30) null, @amount int null, @Preis float null)
as begin
if (@productName != null)
begin
if (@info !=null and @amount !=null and @Preis != null)
begin
update Artikel set Info = @info, Anzahl = @amount, Preis = @Preis where Produktbezeichnung = @productName
end
else if (@info != null)
begin
update Artikel set Info = @info where Produktbezeichnung = @productName
end
else if (@amount!=null)
begin
update Artikel set Anzahl = @amount where Produktbezeichnung = @productName
end
else if (@Preis != null)
begin
update Artikel set Preis = @Preis where Produktbezeichnung = @productName
end
end
else
begin
print ('You must enter the product name!')
end
end
And this is the table.