You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Paul DuBois <pa...@snake.net> on 2001/12/27 20:20:46 UTC

Preferred JSTL idiom to check for NULL values in result set?

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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>