You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by mo...@apache.org on 2001/05/27 18:38:00 UTC

cvs commit: jakarta-taglibs/jdbc/examples/web jdbc.jsp

morgand     01/05/27 09:38:00

  Modified:    jdbc/examples/web jdbc.jsp
  Log:
  added nested query example
  
  Revision  Changes    Path
  1.8       +22 -3     jakarta-taglibs/jdbc/examples/web/jdbc.jsp
  
  Index: jdbc.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/jdbc/examples/web/jdbc.jsp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- jdbc.jsp	2001/05/03 15:42:11	1.7
  +++ jdbc.jsp	2001/05/27 16:38:00	1.8
  @@ -124,7 +124,7 @@
     </sql:execute>
   </sql:preparedStatement>
   
  -<P><B>Showing current contents of the "test_books" table</B></P>
  +<P><B>Nested Query example: Reselecting every row in the table</B></P>
   
   <table>
   <tr><th>id</th><th>name</th><th>description</th></tr>
  @@ -141,6 +141,25 @@
         <sql:wasNotNull>Description: <%= pageContext.getAttribute("description") %></sql:wasNotNull>
         <sql:wasNull>[no description]</sql:wasNull></td>
       </tr>
  +
  +    <!-- okay, now perform the nested query -->
  +    <% int colId = rset4.getInt(1); %>
  +    <sql:statement id="stmt9" conn="conn1">
  +      <sql:query>
  +        select id, name, description from test_books
  +        where id = <%= colId %>
  +      </sql:query>
  +      <sql:resultSet id="rset7">
  +        <tr>
  +          <td><sql:getColumn position="1"/></td>
  +          <td><sql:getColumn position="2"/></td>
  +          <td><sql:getColumn position="3" to="description"/>
  +          <sql:wasNotNull>Description: <%= pageContext.getAttribute("description") %></sql:wasNotNull>
  +          <sql:wasNull>[no description]</sql:wasNull></td>
  +        </tr>        
  +      </sql:resultSet>
  +    </sql:statement>
  +
     </sql:resultSet>
     <tr>
       <td colspan="3">
  @@ -175,13 +194,13 @@
   
   <P><B>Prove that an empty resultset executes the wasEmpty tag</B></P>
   
  -<sql:preparedStatement id="stmt6" conn="conn1">
  +<sql:preparedStatement id="stmt8" conn="conn1">
     <!-- impossible statement -->
     <sql:query>
       select id, name, description from test_books
       where id > 1000
     </sql:query>
  -  <sql:resultSet id="rset4">
  +  <sql:resultSet id="rset6">
       <p>
   
         <!-- show that rowCount works for a no rows -->