问题
I need to connect to remote MS SQL server stored procedure from Tibco BW JDBC palette to retrieve a result set where we won't be knowing the result set column names.
In my local environment I had mocked the procedure to return the expected result set but with dummy column names. Hence while parsing the unresolvedResultSet, error is thrown if the column name in the result set is other than the one defined in the output.
If i use 'result set as schema' option then also its throws error while parsing the result set if the column name is different.
Is there any way to fix this in Tibco BW?
Thanks in Advance.
回答1:
For me sounds like converting procedure output UnresolvedResultsets to column/value schema can help to resolve your issue. You can use standard "Transform XML" activity for transforming $JDBC-Procedure/resultSet/UnresolvedResultsets to column/value schema
Step1 create XSLT file with following content:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:str="http://exslt.org/strings"
xmlns:tns="http://www.*****.com/DMS/Core/Schemas/Index/Schema.xsd"
version="2.0">
<xsl:output method="xml" encoding="UTF-8" indent="yes" />
<xsl:template match="/">
<xsl:element name="ROOTELEMENT">
<xsl:for-each select="//node()[not(exists(child::*))]">
<xsl:if test="name()">
<xsl:element name="Column">
<xsl:element name="Name">
<xsl:value-of select="name()" />
</xsl:element>
<xsl:element name="Value">
<xsl:value-of select="." />
</xsl:element>
</xsl:element>
</xsl:if>
</xsl:for-each>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Step 2 add "Transform XML" activity and specify created in step 1 xslt file as Stylesheet
Step3 map $JDBC-Procedure/resultSet/UnresolvedResultsets to Transform XML input
The result should be like this:
here is link to transform XML tutorial
回答2:
You can try ParsigXML using an "Any Element":
and this is the output i am parsing by:
Hope it works for you.
来源:https://stackoverflow.com/questions/48625153/how-to-parse-unresolved-result-set-in-tibco-bw-jdbc-palette