cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Durrant, Peter" <Peter.Durr...@COGNOS.com>
Subject RE: ESQL Extension
Date Wed, 09 Jan 2002 17:30:08 GMT
Diff of esql.xsl to show changes:
---
Original esql.xsl called oldesql.xsl
Modified esql.xsl called esq.xsl
+ indicates addition
! indicates change
---



*** oldesql.xsl Thu Nov 29 12:09:24 2001
--- esql.xsl Wed Jan  9 12:45:56 2002
***************
*** 207,212 ****
--- 207,213 ----
        <xsp:include>java.sql.Connection</xsp:include>
        <xsp:include>java.sql.Statement</xsp:include>
        <xsp:include>java.sql.PreparedStatement</xsp:include>
+       <xsp:include>java.sql.CallableStatement</xsp:include>
        <xsp:include>java.sql.ResultSet</xsp:include>
        <xsp:include>java.sql.ResultSetMetaData</xsp:include>
        <xsp:include>java.sql.SQLException</xsp:include>
***************
*** 289,294 ****
--- 290,296 ----
          String query;
          Statement statement;
  	PreparedStatement prepared_statement;
+ 	CallableStatement stored_procedure;
          ResultSet resultset;
          ResultSetMetaData resultset_metadata;
          /** the position of the current row in the resultset **/
***************
*** 296,301 ****
--- 298,304 ----
          int max_rows = -1;
          int skip_rows = 0;
  	boolean results;
+ 	boolean stored_procedure_expect_bound_results = false;
        }
  
        private final String getAscii(ResultSet set, String column) {
***************
*** 546,551 ****
--- 549,597 ----
      }
      try {
        <xsl:choose>
+         <!-- this is a stored procedure  -->
+ 	<xsl:when test="esql:stored-proc">
+ 	  try {
+             _esql_query.stored_procedure =
_esql_connection.connection.prepareCall(_esql_query.query);
+           } catch (SQLException _esql_exception_<xsl:value-of
select="generate-id(.)"/>) {
+ 	    throw new RuntimeException("Error preparing stored procedure:
"+_esql_query.query+": "+_esql_exception_<xsl:value-of
select="generate-id(.)"/>.getMessage());
+           }
+           _esql_query.statement = _esql_query.stored_procedure;
+ 	  <xsl:for-each select="esql:query//esql:parameter">
+             try {
+ 	      <xsl:text>_esql_query.stored_procedure.</xsl:text>
+ 
+ 	      <xsl:choose>
+ 	        <xsl:when test="@direction='in'">
+ 	      
+               <xsl:choose>
+                 <xsl:when test="@type">
+                   <xsl:variable name="type"><xsl:value-of
select="concat(translate(substring(@type,1,1),'abcdefghijklmnopqrstuvwxyz','
ABCDEFGHIJKLMNOPQRSTUVWXYZ'),substring(@type,2))"/></xsl:variable>
+                   <xsl:text>set</xsl:text><xsl:value-of
select="$type"/>(<xsl:value-of select="position()"/>,<xsl:call-template
name="get-nested-content"><xsl:with-param name="content"
select="."/></xsl:call-template>);<xsl:text>
+ </xsl:text>
+                 </xsl:when>
+ 		<xsl:otherwise>
+                   <xsl:text>setString(</xsl:text><xsl:value-of
select="position()"/>,String.valueOf(<xsl:call-template
name="get-nested-string"><xsl:with-param name="content"
select="."/></xsl:call-template>));<xsl:text>
+ </xsl:text>
+                 </xsl:otherwise>
+ 	       </xsl:choose>
+ 
+                 </xsl:when>
+ 		<xsl:when test="@direction='out'">
+ 		  <xsl:text>registerOutParameter(</xsl:text><xsl:value-of
select="position()"/>,<xsl:value-of select="@type"/>);
+ 		  _esql_query.stored_procedure_expect_bound_results = true;
+                 </xsl:when>
+        	       </xsl:choose>
+             } catch (SQLException _esql_exception_<xsl:value-of
select="generate-id(.)"/>) {
+               throw new RuntimeException("Error setting parameter on
statement: "+_esql_query.query+": "+_esql_exception_<xsl:value-of
select="generate-id(.)"/>);
+             }
+           </xsl:for-each>
+           try {
+ 	    _esql_query.results = _esql_query.stored_procedure.execute();
<!-- stored procedure execute returns false for outputs that need to be
bound e.g. Oracle -->
+           } catch (SQLException _esql_exception_<xsl:value-of
select="generate-id(.)"/>) {
+             throw new RuntimeException("Error executed stored procedure:
"+_esql_query.query+": "+_esql_exception_<xsl:value-of
select="generate-id(.)"/>);
+           }	
+         </xsl:when>
          <!-- this is a prepared statement -->
          <xsl:when test="esql:query//esql:parameter">
            try {
***************
*** 592,600 ****
            getLogger().debug("esql query: "+_esql_query.query);
          </xsl:otherwise>
        </xsl:choose>
!       if (_esql_query.results) {
          do {
            _esql_query.resultset = _esql_query.statement.getResultSet();
            _esql_query.resultset_metadata =
_esql_query.resultset.getMetaData();
            _esql_query.position = 0;
            if (_esql_connection.use_limit_clause == 0 &amp;&amp;
_esql_query.skip_rows &gt; 0) {
--- 638,650 ----
            getLogger().debug("esql query: "+_esql_query.query);
          </xsl:otherwise>
        </xsl:choose>
!       if (_esql_query.results ||
_esql_query.stored_procedure_expect_bound_results) {
          do {
+ 	  if (_esql_query.results)
  	    _esql_query.resultset = _esql_query.statement.getResultSet();
+ 	  else
+ 	    _esql_query.resultset =
(ResultSet)_esql_query.stored_procedure.getObject(1);
+   
  	  _esql_query.resultset_metadata =
_esql_query.resultset.getMetaData();
            _esql_query.position = 0;
            if (_esql_connection.use_limit_clause == 0 &amp;&amp;
_esql_query.skip_rows &gt; 0) {


This message may contain privileged and/or confidential information.  If you
have received this e-mail in error or are not the intended recipient, you
may not use, copy, disseminate, or distribute it; do not open any
attachments, delete it immediately from your system and notify the sender by
e-mail promptly that you have done so.  Thank You.

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message