Well, I’m sorry to say that it does not work for me, I get:

file:///C:/xalan-j_2_7_0/samples/extensions/sql/pquery/dbtest.xsl; Line #41; Column #70; java.sql.SQLException: At least one parameter to the current statement is uninitialized.

file:///C:/xalan-j_2_7_0/samples/extensions/sql/pquery/dbtest.xsl; Line #51; Column #25; Error in Query

 

When fiddling around however it seems that there is something amiss in the use of:

<!-- Build a CSV list of parameter types -->

<xsl:param name="q1type" select="int" />

Whenever I try to make a list, e.g. “int,string” (which would be a proper CSV list to my understanding) I get:

javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: Ytterligare otillåtna tecken: ',', 'string'

which is OK so I try to do an alternate pquery invocation:

<xsl:variable name="table" select="sql:pquery($db, $q1, 'int,string')"/> , I get:

file:///C:/xalan-j_2_7_0/samples/extensions/sql/pquery/dbtest.xsl; Line #51; Column #25; Error in Query

 

When moving the type definitions into the Query structure (attribute “type”) and removing the third parameter from the “sql:pquery” statement  it works all the time regardless of the type values I enter (e.g. string instead of int).

 

All tests above done with the Derby database. I will try some more on z/OS DB2 after New Year.

 

So, till then: Happy Holidays…….

 

Lars

 

Från: Christoffer Bruun [mailto:cdbruun@flyingpigs.dk]
Skickat: den 20 december 2012 09:17
Till: j-users@xalan.apache.org
Ämne: Re: Sql extension - parameterized query

 

Hi,

I have no direct expericence with the Sql extension, but I think you should use
<xsl:variable name="qparam" select="//QUERY/*"/>
- otherwise it may assume that you want to add only 1 parameter (the 1 QUERY element) with a text value of SPI010000004016

Best regards
Christoffer Bruun


Den 20-12-2012 09:02, lars.bjerges@swedbank.se skrev:

...



What I would like to do is to have  a xml fragment containing the parameter values:

<QUERY>

<KOD_TXT_GRP>SPI01</KOD_TXT_GRP>

<KODTXT>0000004016</KODTXT>

</QUERY>

And, in the stylesheet have the following code:

 

<xsl:param name="q1" select="'SELECT HANDAT,VALFRI_TEXT_RAD FROM DB2T.SPATTXT WHERE KOD_TXT_GRP = ? AND KODTXT = ?'"/>

<xsl:variable name="qparam" select="//QUERY"/>

<xsl:value-of select="sql:addParameterFromElement($db,$qparam)"/>

<xsl:param name="q1type" select="'string,string'"/>

<xsl:variable name="table" select="sql:pquery($db,$q1,$q1type)"/>