Here is what it says in the doc:
"The "rowCount" tag prints out the number of rows retrieved from the
database. It can be used inside a ResultSet tag to provide a running count
of rows retreived, or after the ResultSet tag to display the total number.
See the Tag Reference for examples. Using the tag before the ResultSet
will produce an error."
Is there any way to test rowCount before the ResultSet?
That is, if I have "catTable":
catName color furType
----------------------------------
Jasmine Tortoise Shell long
Honey Orange Tabby short
Corinna Calico short
Pearl Silver Tabby long
And my SELECT statement is:
SELECT * FROM catTable WHERE color="Black";
Then, because there does not seem to be a way to test the sql query to see
if it returns zero rows, the table headings will always be printed, even
if no table rows print (assuming for this example that the user chose
"Black" for catColor in the HTML form):
<%
String myColor = request.getParameter("catColor");
%>
<sql:statement id="stmt1" conn="conn1">
<sql:query>
SELECT * FROM catTable WHERE color='<%= myColor %>'
</sql:query>
<!-- I want to have a conditional test here
so that is the query above returns zero rows,
the following HTML does not get printed.
-->
<table>
<tr>
<td>catName</td>
<td>color</td>
<td>furType</td>
</tr>
<!-- need to NOT print the above HTML if zero rows
in query! -->
<sql:execute ignoreErrors="true"/>
<sql:resultSet id="rset2">
<tr>
<td><sql:getColumn colName="catName"/></td>
<td><sql:getColumn colName="color"/></td>
<td><sql:getColumn colName="furType"/></td>
</tr>
</sql:resultSet>
<!-- same here, don't print if zero rows -->
</table>
<!-- how? -->
</sql:statement>
That is, because of the ignoreErrors-"true", if there are zero rows,
nothing gets printed out inside the resultSet block. However, the
literal table header row always gets printed.
Thanks for any advice.
-Carole
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Carole E. Mah [EMAIL PROTECTED]
Senior Programmer/Analyst
Brown University Scholarly Technology Group
phn 401-863-2669
fax 401-863-9313
http://www.stg.brown.edu/
personal: http://www.stg.brown.edu/~carolem/
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>