Declare @num int
set @num =0
while(@num<9)
begin
set @num= @num + 1
if not exists(Select Attrid FROM HVC_Statistics_Setting WHERE Attrid =@num)
begin
INSERT INTO HVC_Statistics_Setting(PortalID,AttrID,AttrName,StringValue,FloatValue)
VALUES (@PortalID,@num,'','',Case
When @num=1 then @TotalAccessed
When @num=2 then @AllArticlesNum
When @num=3 then @AllArticleHits
When @num=4 then @MonthTotalUpdated
When @num=5 then @MonthArticleHits
When @num=6 then @WeekArticleUpdated
When @num=7 then @WeekArticleHits
When @num=8 then @Score
end)
end
else
begin
Update HVC_Statistics_Setting SET
PortalID=@PortalID,
AttrID=@num,
AttrName='',
StringValue='',
FloatValue= Case
When @num=1 then @TotalAccessed
When @num=2 then @AllArticlesNum
When @num=3 then @AllArticleHits
When @num=4 then @MonthTotalUpdated
When @num=5 then @MonthArticleHits
When @num=6 then @WeekArticleUpdated
When @num=7 then @WeekArticleHits
When @num=8 then @Score
end
where Attrid =@num
end
end
set @num =0
while(@num<9)
begin
set @num= @num + 1
if not exists(Select Attrid FROM HVC_Statistics_Setting WHERE Attrid =@num)
begin
INSERT INTO HVC_Statistics_Setting(PortalID,AttrID,AttrName,StringValue,FloatValue)
VALUES (@PortalID,@num,'','',Case
When @num=1 then @TotalAccessed
When @num=2 then @AllArticlesNum
When @num=3 then @AllArticleHits
When @num=4 then @MonthTotalUpdated
When @num=5 then @MonthArticleHits
When @num=6 then @WeekArticleUpdated
When @num=7 then @WeekArticleHits
When @num=8 then @Score
end)
end
else
begin
Update HVC_Statistics_Setting SET
PortalID=@PortalID,
AttrID=@num,
AttrName='',
StringValue='',
FloatValue= Case
When @num=1 then @TotalAccessed
When @num=2 then @AllArticlesNum
When @num=3 then @AllArticleHits
When @num=4 then @MonthTotalUpdated
When @num=5 then @MonthArticleHits
When @num=6 then @WeekArticleUpdated
When @num=7 then @WeekArticleHits
When @num=8 then @Score
end
where Attrid =@num
end
end