/****** 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变量