johng 01/08/01 11:29:16
Modified: java/samples/extensions/sql/pquery dbtest.xsl
Log:
dded new connect method and error checking
Submitted by: John Gentilin
Revision Changes Path
1.3 +22 -2 xml-xalan/java/samples/extensions/sql/pquery/dbtest.xsl
Index: dbtest.xsl
===================================================================
RCS file: /home/cvs/xml-xalan/java/samples/extensions/sql/pquery/dbtest.xsl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- dbtest.xsl 2001/05/01 21:11:36 1.2
+++ dbtest.xsl 2001/08/01 18:29:16 1.3
@@ -17,7 +17,14 @@
<xsl:param name="cinfo" select="//DBINFO" />
<xsl:template match="/">
- <xsl:variable name="db" select="sql:new($cinfo)"/>
+ <xsl:variable name="db" select="sql:new()"/>
+
+ <!-- Connect to the database with minimal error detection -->
+ <xsl:if test="not(sql:connect($db, $cinfo))" >
+ <xsl:message>Error Connecting to the Database</xsl:message>
+ <xsl:copy-of select="sql:getError($db)/ext-error" />
+ </xsl:if>
+
<HTML>
<HEAD>
<TITLE>List of products</TITLE>
@@ -26,7 +33,20 @@
<TABLE border="1">
<xsl:variable name="qparam" select="//QUERY"/>
<xsl:value-of select="sql:addParameterFromElement($db, $qparam)"/>
+
<xsl:variable name="table" select='sql:pquery($db, $q1, $q1type
)'/>
+
+ <!--
+ Let's include Error Checking, the error is actually stored
+ in the connection since $table will be either data or null
+ -->
+
+ <xsl:if test="not($table)" >
+ <xsl:message>Error in Query</xsl:message>
+ <xsl:copy-of select="sql:getError($db)/ext-error" />
+ </xsl:if>
+
+
<TR>
<xsl:for-each select="$table/row-set/column-header">
<TH><xsl:value-of select="@column-label"/></TH>
@@ -47,4 +67,4 @@
<TD><xsl:value-of select="text()"/></TD>
</xsl:template>
-</xsl:stylesheet>
\ No newline at end of file
+</xsl:stylesheet>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]