ASF Bugzilla – Attachment 10572 Details for
Bug 21647
Select statements with no rows selected problem
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Test case (based on examples and using hsqldb)
21647.jsp (text/plain), 2.55 KB, created by
Felipe Leme
on 2004-02-26 19:38:32 UTC
(
hide
)
Description:
Test case (based on examples and using hsqldb)
Filename:
MIME Type:
Creator:
Felipe Leme
Created:
2004-02-26 19:38:32 UTC
Size:
2.55 KB
patch
obsolete
><%@ taglib uri="http://java.sun.com/jstl/sql" prefix="sql" %> ><%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %> ><%@ taglib uri="http://jakarta.apache.org/taglibs/dbtags" prefix="db" %> > ><c:set var="jdbcUrl" value="jdbc:hsqldb:."/> ><c:set var="jdbcDriver" value="org.hsqldb.jdbcDriver"/> ><c:set var="jdbcUser" value="sa"/> > ><sql:setDataSource scope="page" driver="${jdbcDriver}" url="${jdbcUrl}" user="${jdbcUser}"/> > ><sql:transaction> > >Creating data.... ><sql:update> >CREATE TABLE test_books (id INTEGER NOT NULL PRIMARY KEY, name VARCHAR(100) NOT NULL, description VARCHAR(200)) >INSERT INTO test_books (id, name) VALUES (1, 'Programming Perl'); >INSERT INTO test_books (id, name) VALUES (2, 'On Liberty'); ></sql:update> > >ok<br> > > ><P><B>Opening connection</B></P> > ><db:connection id="conn1"> > <db:url><c:out value="${jdbcUrl}"/></db:url> > <db:driver><c:out value="${jdbcDriver}"/></db:driver> > <db:userId><c:out value="${jdbcUser}"/></db:userId> ></db:connection> > ><p><b>For fun, pretend that the ids are British money in the left column, > and French decimals in the right</b></p> > ><table> ><db:preparedStatement id="stmt7" conn="conn1"> > <db:query> > select id from test_books > order by 1 > </db:query> > <db:resultSet id="rset5"> > <tr> > <td><db:getNumber colName="id" format="CURRENCY" locale="en_GB"/></td> > <td><db:getNumber position="1" format="0.00" locale="fr_FR"/></td> > </tr> > </db:resultSet> > <tr> > <td> > <db:wasEmpty>No rows retrieved.</db:wasEmpty> > <db:wasNotEmpty><db:rowCount/> rows retrieved.</db:wasNotEmpty> > </td> > </tr> ></db:preparedStatement> ></table> > > ><P><B>Prove that an empty resultset executes the wasEmpty tag</B></P> > ><db:preparedStatement id="stmt8" conn="conn1"> > <!-- impossible statement --> > <db:query> > select id, name, description from test_books > where id > 1000 > </db:query> > <db:resultSet id="rset6"> > <p> > > <!-- show that rowCount works for a no rows --> > retrieved row <db:rowCount/> > > <db:getColumn position="1"/> > <db:getColumn position="2"/> > <db:getColumn position="3" to="description"/> > <db:wasNotNull>Description: <%= pageContext.getAttribute("description") %></db:wasNotNull> > <db:wasNull>[no description]</db:wasNull> > </p> > </db:resultSet> > <p> > <db:wasEmpty>no rows retrieved</db:wasEmpty> > <db:wasNotEmpty>D'OH!!!<db:rowCount/> rows retrieved.</db:wasNotEmpty> > </p> ></db:preparedStatement> > > ><P><B>Closing the database connection</B></P> > ><db:closeConnection conn="conn1"/> > ><p><b>Success!</b></p> ></body> ></html> > > > ></sql:transaction> > > > > >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 21647
: 10572 |
10573
|
10574