Назначение значений нескольким переменным из инструкции select в блоке PL SQL
Assign values to multiple variables from select statement in pl sql block
Declare @count int, @Leadownernew int,@leadownerold int,@leadid int
select Leadownernew,leadownerold,leadid,Id from #TempTable where Id=@count now I want to assign values as set @Leadownernew =Leadownernew set @leadownerold=leadownerold -- SET @Leadownernew = ( select Leadownernew ) @leadownerold= ( leadownerold, Id from #TempTable where Id=@count);
Что я уже пробовал:
Declare @count int, @Leadownernew int,@leadownerold int,@leadid int DECLARE @TopRelatedItemId int; SET @TopRelatedItemId = ( SELECT max(id) RelatedItemId FROM #TempTable ) --print ''+@TopRelatedItemId -- Declare @count int; set @count=1; while(@count<=@TopRelatedItemId) begin select Leadownernew,leadownerold,leadid,Id from #TempTable where Id=@count -- SET @Leadownernew = ( select Leadownernew ) @leadownerold= ( leadownerold, Id from #TempTable where Id=@count); -- select Leadownernew,leadownerold,leadid,Id from #TempTable where Id=@count --where -- where --set @Leadownernew=Leadownernew; set @count=@count+1; End