您的位置:首页 > 移动开发 > Objective-C

关于XML 类型字段的修改

2011-07-28 15:44 281 查看
/****** Object:  StoredProcedure [dbo].[Ywcd_UpdateOrderFormState]    Script Date: 07/28/2011 15:38:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[Ywcd_UpdateOrderFormState]
-- Add the parameters for the stored procedure here
@OrderFormId int,--订单Id
@SupplyOid int,--原文提供机构Id
@OrderFormState nvarchar(60)--更新的订单状态
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
declare @stateId int;
declare @xml xml;
select @xml=DealRule from Ywcd_OrderFormLog where Id=@OrderFormId
set @xml.modify('replace value of (/Root/OrderFormState/text())[1] with sql:variable("@OrderFormState")')
select @stateId=Id from Ywcd_OrderFormStateDic where  Name=@OrderFormState
-- Insert statements for procedure here
update Ywcd_OrderFormLog set OrderFormStateId=@stateId,SupplyOid=@SupplyOid,
DealTime=GETDATE(), DealRule=@xml
where Id=@OrderFormId
select DealRule from Ywcd_OrderFormLog where Id=@OrderFormId
END

总结:modify方法,更新xml内容用replace
(/Root/OrderFormState/text())[1] 为修改节点内容,而非修改属性值
sql:variable("@OrderFormState") 调用sql变量
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息