Background
I'm using Oralce as database and H2 Embedded in-memory database for integration tests.
I've created some tables in H2 and was able to get some inserted data. However, I could not retrieve the current sequence value for the sequence I've created in H2.
I'm aware that Oracle and H2 are not the same and use similar but different syntax. I'm also aware that you can define some alias in H2 in-memory database and embed a java code in-lieu of Oracle SQL functions. This gives me a hint that there must be a workaround in retrieving the sequence value using Oracle's syntax over H2 database.
The question
How do I make Oracle's syntax for selecting the current value of a sequence work on H2? Do I need to create alias and write embedded java code in-lieu of Oracle's syntax? What are my options?
The code under test uses the following hypothetical but similar SQL
select myschema.mysequence.nextval from dual
But I'm getting error like the following
org.h2.jdbc.JdbcSQLSyntaxErrorException: Column "nextval" not found [42122-199]
It's probably obvious that that isn't going to work because of the difference in syntax. I'm looking for a workaround without having to change the code being tested which uses Oracle's syntax.
Updates
I'm using Spring JDBC's EmbeddedDatabaseBuilder which means I don't connect to a separate independent H2 database instance but to an instance created on-the-fly in which I include DDL scripts to create the DB objects.
The following post along with the accepted answer helped solved it.
Does Spring embedded database support different SQL dialects?