sql server - Nested If Statement with Insert Statements in SQL -
so writing stored procedure webpage pull 3 parameters webpage , store 1 based on values of other 2.
alter procedure [dbo].[pmrassigndate] @pmrid int, @department varchar(255), @assigndate date begin if exists(select * [productinformation].[dbo].[pmrinformation] pmrid = @pmrid) begin if @department='engineering' begin insert [dbo].[pmrinformation] (engineeringapprovaldate) values (@assigndate) end else if (@department='operations') begin insert [dbo].[pmrinformation] (operationsapprovaldate) values (@assigndate) end else if (@department='ame') begin insert [dbo].[pmrinformation] (ameapprovaldate) values (@assigndate) end else if @department='finance' begin insert [dbo].[pmrinformation] (financeapprovaldate) values (@assigndate) end else if @department='marketing' begin insert [dbo].[pmrinformation] (marketingapprovaldate) values (@assigndate) end else if @department='tester' begin insert [dbo].[pmrinformation] (engineeringapprovaldate, marketingapprovaldate, ameapprovaldate, financeapprovaldate, operationsapprovaldate) values (@assigndate,@assigndate,@assigndate,@assigndate,@assigndate) end end end
so stored procedure must find row pmrid equals sent @pmrid webpage. must use @department variable determine department store approval date @assigndate into. far procedure runs not storing date in correct row. create new row , insert approval date new row. please help. thanks!
from description, sounds rather update row insert row.
try changing inserts this:
update dob.pmrinformation
set = @assigndate
pmrid = @pmrid
Comments
Post a Comment