有人可以告诉我如何在设置参数之前检查value has属性并获取数据吗?
这是我的XML:
<Setup>
<Include Type="Product">
<Value uomid="8078">468908_3:9500;2:10000;</Value>
<Value>468906_3:9500;2:10000;</Value>
</Include>
</Setup>
这是我获取数据的存储过程
SELECT *
FROM (
SELECT YS_PromotionID,
PromotionName,
PromotionDescription,
PromotionSetup,
IsActive,
FromDate,
ToDate,
ShowWhenUsed,
SortOrder,
dbo.YS_GetLoyaltyProgramNameInPromotion('+CAST(@accountID AS VARCHAR)+',PromotionSetup) as LoaiThanhVien,
(PromotionSetup.query(''
for $PS in Setup/Include[@Type = ''''Product'''']/Value[@uomid='''''+CAST(@uomID as nvarchar)+'''''][text()]
where contains($PS, ''''' + CAST(@productID AS NVARCHAR) + '_'''') or $PS = ''''' + CAST(@productID AS NVARCHAR) + '''''
return data($PS)
'')).value(''(.)'', ''nvarchar(max)'') as InfoProductPromotion
FROM YS_Promotion
WHERE YS_AccountID = ' + CAST(@accountID AS NVARCHAR) + ' AND
(''' + CAST(@checkAll AS NVARCHAR) + ''' = 1 OR CONVERT(DATE, GETDATE()) >= CONVERT(DATE, FromDate) ) AND
(''' + CAST(@checkAll AS NVARCHAR) + ''' = 1 OR CONVERT(DATE, GETDATE()) <= CONVERT(DATE, ToDate) ) AND
(''' + CAST(@checkAll AS NVARCHAR) + ''' = 1 OR IsActive = 1) AND
(''' + CAST(@branchID AS NVARCHAR) + ''' = 0 OR ((PromotionSetup.exist(''Setup/Include[@Type = ''''Branch'''']/Value[text() = ''''' + CAST(@branchID AS NVARCHAR) + ''''']'') = 1 or PromotionSetup.exist(''Setup/Include[@Type = ''''Branch'''']/Value[text() = ''''0'''']'') = 1))) AND
('''+CAST(@applyForAllCustomer AS varchar) +''' = ''1'' or dbo.YS_fcCheckPromotionApplyForCustomerLoyalty(YS_PromotionID) = 0)
) AS Temp WHERE InfoProductPromotion <> ''''
--) AS Temp WHERE InfoProductPromotion <> '''' or (''' + CAST(@checkAll AS NVARCHAR) + ''' <> 1 AND PromotionSetup.exist(''Setup/Include[@Type = ''''ALLProduct'''']/Value[text() = ''''1'''']'') = 1 )
order by ' + @sortExpression
根据我的XML文件,我有2个值,1个属性是uomid,另一个不是。
我的问题在这里:
首先,我想设置@productID
并获得价值。在我使用参数Value
选择@uomid
属性之前,我想检查该值是否具有属性,之后我将在PromotionSetup.query
中设置2个参数来获取数据。
有人可以帮我编辑商店程序来完成吗?