tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul DuBois <p...@snake.net>
Subject Preferred JSTL idiom to check for NULL values in result set?
Date Thu, 27 Dec 2001 19:20:46 GMT
Is there a preferred (i.e., idiomatic) way to check for a NULL
value in a query result?  Suppose I have the following code:

<sql:query var="rs" dataSource="$conn">
     SELECT NOW(), VERSION(), USER(), DATABASE()
</sql:query>

<c:forEach var="row" begin="1" items="$rs.rows">
<p>
Local time on the server is
     <c:expr value="$row.get(1)"/>.
The server version is
     <c:expr value="$row.get(2)"/>.
The current user is
     <c:expr value="$row.get(3)"/>.
The current database is
     <c:expr value="$row.get(4)"/>.
</p>
</c:forEach>

If no database currently is selected, DATABASE() may return NULL and
I'd like to print "NONE".  How should I do this?  I looked through the
sql tags part of the JSTL docs to see what it said about testing for
NULL return values, but I didn't find anything.

--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>


Mime
View raw message