0

在查询中,我使用的是 SQL 函数(它调用 .NET 函数进行 xml 转换)

SELECT ApplyXMLTransform((subquery which returns XML type), (subquery which gets the XSLT) FROM SomeTable

当函数 ApplyXMLTransform 遇到异常时,整个查询就会爆炸......有没有办法防止异常破坏整个记录集(查询明智,我意识到我可以修改函数以处理托管代码中的异常)?

异常本身也是一个谜,因为当我查询罪魁祸首的记录时,我没有看到会构成异常的无效字符等......但这是另一个蠕虫罐......这是错误:

Msg 6522, Level 16, State 1, Line 3
A .NET Framework error occurred during execution of user-defined routine or aggregate "ApplyXsltTransform": 
System.Xml.XmlException: Invalid character in the given encoding. Line 21, position 417.
System.Xml.XmlException: 
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.InvalidCharRecovery(Int32& bytesCount, Int32& charsCount)
   at System.Xml.XmlTextReaderImpl.GetChars(Int32 maxCharsCount)
   at System.Xml.XmlTextReaderImpl.ReadData()
   at System.Xml.XmlTextReaderImpl.ParseText(Int32& startPos, Int32& endPos, Int32& outOrChars)
   at System.Xml.XmlTextReaderImpl.ParseText()
   at System.Xml.XmlTextReaderImpl.ParseElementContent()
   at System.Xml.XmlWriter.WriteNode(XmlReader reader, Boolean defattr)
   at System.Data.SqlTypes.SqlXml.CreateMemoryStreamFromXmlReader(XmlReader reader)
   at System.Data.SqlTypes.SqlXml..ctor(XmlReader value)
   at NF.Sql.Extensions.XSLTTransform.Transform(SqlXml inputDataXML, SqlXml inputTransformXML)
.
4

0 回答 0