Hi,
PostgreSQL also throws an error if NEXTVAL was not yet called:
drop sequence abc;
create sequence abc;
select currval('ABC');
-- PostgreSQL: ERROR: currval of sequence "abc" is not yet defined in
this session 55000/0
-- H2: 0
select nextval('ABC'); -- 1
select currval('ABC'); -- 1
It looks like in PostgreSQL and Oracle, CURRVAL is session specific. I
didn't know that. In H2, CURRVAL is the last value (independent of the
session). This is an incompatibility, I guess I need to fix that.
The current value is also available in the system table
INFORMATION_SCHEMA.SEQUENCES, in that case it's probably OK to return
the last used value (as done now), or maybe NULL if NEXTVAL was never
called by any session.
Regards,
Thomas