Hi,

Sorry I can't reproduce the problem so far. My test case is:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.h2.tools.DeleteDbFiles;

public class TestDb2 {
    public static int getMaxRev(Connection conn)
        throws SQLException {
        ResultSet rs = conn.createStatement().
            executeQuery("select max(id) from test");
        rs.next();
        System.out.println(" getMaxRev: " + rs.getInt(1));
        return rs.getInt(1);
    }
    public static void main(String[] a) throws Exception {
        Class.forName("org.h2.Driver");
        DeleteDbFiles.execute("data/test", "test", true);
        Connection conn = DriverManager.getConnection(
            "jdbc:h2:data/test/test", "sa", "sa");
        Statement stat = conn.createStatement();
        stat.execute("create table test(id identity) " +
            "as select x from system_range(1, 2);");
        stat.execute("CREATE ALIAS GET_MAX_REV " +
            "FOR \"TestDb2.getMaxRev\"");
        stat.execute("CREATE VIEW THINGY AS " +
            "SELECT * FROM TEST WHERE ID<=GET_MAX_REV()");
        ResultSet rs;
        System.out.println("SELECT * FROM THINGY");
        rs = stat.executeQuery("SELECT * FROM THINGY");
        while (rs.next()) {
            System.out.println("a: " + rs.getString(1));
        }
        stat.execute("insert into test " +
            "select x from system_range(10, 11);");
        System.out.println("SELECT * FROM THINGY");
        rs = stat.executeQuery("SELECT * FROM THINGY");
        while (rs.next()) {
            System.out.println("b: " + rs.getString(1));
        }
        conn.close();
    }
}

Could you change my test case so it fails?

Regards,
Thomas

On Fri, Jul 24, 2009 at 10:30 PM, nigelm<[email protected]> wrote:
>
> Hi
>
> I have migrated away from HSQLDB mostly with success, save for 1
> issue.
>
> We create some database views that use a function in order to control
> their results. E.g:
>
> CREATE ALIAS GET_MAX_REV FOR "net.foo.bar.getMaxRev"
>
> CREATE VIEW THINGY AS
> SELECT * FROM WIDGETS
> WHERE REV <= GET_MAX_REV()
>
> This works, but with one shortcoming. The getMaxRev function is
> volatile, so successive calls to
> SELECT * FROM THINGY
>
> Ought to potentially return dramatically different results. But I can
> see by setting a breakpoint in getMaxRev that periodically it is not
> being called.
>
> I assume that either the function result, or the query result has been
> cached somewhere. Is there a way to declare that the function is
> volatile (perhaps by passing an unused timestamp parameter) ?
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to