private void testSimple() throws Exception {
deleteDb("recursiveQueries");
Connection conn = getConnection("recursiveQueries");
Statement stat;
PreparedStatement prep, prep2;
ResultSet rs;
stat = conn.createStatement();
rs = stat.executeQuery("with recursive t(n) as " +
"(select 1 union all select n+1 from t where n<3) " +
"select * from t");
assertTrue(rs.next());
assertEquals(1, rs.getInt(1));
assertTrue(rs.next());
assertEquals(2, rs.getInt(1));
assertTrue(rs.next());
assertEquals(3, rs.getInt(1));
assertFalse(rs.next());
prep = conn.prepareStatement("with recursive t(n) as " +
"(select 1 union all select n+1 from t where n<3) " +
"select * from t where n>?");
prep.setInt(1, 2);
rs = prep.executeQuery();
assertTrue(rs.next());
assertEquals(3, rs.getInt(1));
assertFalse(rs.next());
prep.setInt(1, 1);
rs = prep.executeQuery();
assertTrue(rs.next());
assertEquals(2, rs.getInt(1));
assertTrue(rs.next());
assertEquals(3, rs.getInt(1));
assertFalse(rs.next());
prep = conn.prepareStatement("with recursive t(n) as " +
"(select @start union all select n+@inc from t where n<@end) " +
"select * from t");
prep2 = conn.prepareStatement("select @start:=?, @inc:=?, @end:=?");
prep2.setInt(1, 10);
prep2.setInt(2, 2);
prep2.setInt(3, 14);
prep2.execute();
rs = prep.executeQuery();
assertTrue(rs.next());
assertEquals(10, rs.getInt(1));
assertTrue(rs.next());
assertEquals(12, rs.getInt(1));
assertTrue(rs.next());
assertEquals(14, rs.getInt(1));
assertFalse(rs.next());
prep2.setInt(1, 100);
prep2.setInt(2, 3);
prep2.setInt(3, 103);
prep2.execute();
rs = prep.executeQuery();
assertTrue(rs.next());
assertEquals(100, rs.getInt(1));
assertTrue(rs.next());
assertEquals(103, rs.getInt(1));
assertFalse(rs.next());