获取“ xml数据类型方法的参数1”修改”。必须是字符串文字”,同时在xml中插入属性 [英] Getting 'The argument 1 of the xml data type method "modify" must be a string literal' while inserting a attribute in xml
本文介绍了获取“ xml数据类型方法的参数1”修改”。必须是字符串文字”,同时在xml中插入属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试以下代码。但是,获取 xml数据类型方法 modify的参数1必须是字符串文字错误。大量搜索但找不到任何解决方案
Trying the following code. But getting 'The argument 1 of the xml data type method "modify" must be a string literal' error. searched alot but cant find any solution for this problem
SET @Path = '/@ParentNodeName/@NodeName/child::*'
SET @x.modify('insert attribute status {sql:variable("@status")}
as first into (' + @Path + ')[1]')
推荐答案
问题不在于sql:variable值是尝试插入-这是将XPath包含到Modify语句中的方式。您不能将该命令串在一起-您需要使用文字:
The problem isn't the sql:variable with the value you're trying to insert - it's the way you include the XPath into your modify statement. You cannot string together that command - you need to use a literal:
所以您需要使用:
SET @x.modify('insert attribute status {sql:variable("@status")}
as first into (/Parent/Node/)[1]')
然后就可以了。
这篇关于获取“ xml数据类型方法的参数1”修改”。必须是字符串文字”,同时在xml中插入属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文