我有以下存储过程:
ALTER PROCEDURE [dbo].[UpPro]
(
@PN varchar(200),
@xml xml,
@gVa varchar(10),
)
AS
/* update the gender */
BEGIN
SET NOCOUNT ON;
Select @gVa = t1.[Gender]
From [myDb].[dbo].[myTable1] t1 --replace Value2 and table to the table which is updated through SSIS
Where t1.Name = @PN
PRINT @gVa //displays 'F'
Set @xml.modify('replace value of (/root/Phys/gender/text())[1] with sql:variable("@gVa")');
END
/* once all the node has been "temporarily" changed, update the table columns for the provider */
BEGIN
--update the table after casting dummy xml variable
Update [myDb].[dbo].[TC]
Set [chtml] = cast(cast(@xml as nvarchar(max)) as ntext)
Where [ctitle] = @PN
END
当我运行查询时,出现以下错误:
Msg 5302,Level 16,State 1,Procedure UpPro,Line 115
Mutator' modify()' on' @ xml'不能在空值上调用。
如何解决错误。我正在尝试更新chtml
表中ntext
类型的列(TC
)中的xml值。
如果我需要提供更多信息,请告诉我。
只是为了测试代码,我只是尝试了以下内容,它仍然给出了同样的错误:
DECLARE @gVa varchar(10)
DECLARE @xml xml
Select @gVa = t1.[Gender]
From [myDb].[dbo].[myTable1] t1 --replace Value2 and table to the table which is updated through SSIS
Where t1.Name = 'Doctor 1'
PRINT @gVa
If @xml IS NOT NULL
BEGIN
Set @xml.modify('replace value of (/root/Phys/gender/text())[1] with sql:variable("@gVa")');
END
Else
BEGIN
PRINT 'NOT WORK'
END
保持打印NOT WORK
原始列(chtml
)数据:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<Phys>
<gender>M</gender>
</Phys>
</root>
执行上述SP后,gender
应为F
而不是M
答案 0 :(得分:2)
错误实际上说明了一切,.directive('datePicker', function(){
return{
restrict: 'E',
link: function(scope, element, attributes){
$('.tdate').datepicker({
onSelect: function (selectedDate) {
scope.ngModel = selectedDate;
scope.$apply();
}
});
},
scope: {
ngModel: '='
},
template: '<input type="text" class="tdate">'
};
});
为空且不允许。
摄制:
@XML
Msg 5302,Level 16,State 1,Line 4 Mutator&#39; modify()&#39; on&#39; @ X&#39;不能 被调用空值。
在修改之前检查null。
declare @X xml;
set @X.modify('replace value of text()[1] with "1"');