这是我的应用程序用来设置表(网格)数据的函数,就像在常规标头字段中一样。例如,如果我在标题中选择“是”,则该网格和行中的每个数据为“否”,它将变为“是”。但是我无法理解他们如何将实时Web表单中的数据作为XML。我该如何获取XML字符串。
create function dbo.fCore_Var0 (@s xml)
returns decimal(17, 2)
as
begin
declare @iCurrentRow int
declare @iTotalRowCount int
declare @iTotalYesCount int
select @iCurrentRow=@s.value('(/Fields/Header/CurrentRow)[1]', 'int') -- returns curr row index
if @iCurrentRow >= 0
begin
declare @tbPrincipleTags as table (iIdd int identity(0,1),iProductId int,iCompletionStatus int)
insert into @tbPrincipleTags(iProductId ,iCompletionStatus)
select
pd.value('iProductId[1]', 'int'),
pd.value('iCompletionStatus[1]', 'int')
from
@s.nodes('/Fields/BodyData/AllRows') as x(Rec) -- returns all products
cross apply
@s.nodes('/Fields/BodyData/AllRows/BodyRow') as i(pd)
delete from @tbPrincipleTags where iProductId=0
select @iTotalRowCount = count(*)
from @tbPrincipleTags
select @iTotalYesCount = count(*)
from @tbPrincipleTags
where iCompletionStatus = 1
if @iTotalYesCount = @iTotalRowCount
return 'YES'
else
return 'NO'
end
return 'NO'
end
go
答案 0 :(得分:0)
您的标题告诉我,您想了解此功能。但是文字中的问题是
我该如何获取XML字符串。
好吧,首先回答这个问题:这对发件人来说是最好的。但是您可以启动“ SQL-Server-Profiler” 并监视运行的查询。参数将显示在探查器中。
要了解您的功能:
XML似乎包含几行。这些行将填充包含iProductID
和iCompletionStatus
的临时表。
所有带有iProductId=0
的行都被推到一边。
仅在行数与完成的行数相同的情况下才返回YES
。换句话说:当所有行完成时,您将得到一个YES
。
希望这对您有帮助...