Hi,
I'm new to H2 SQL programming, with a modicum of experience in Oracle
SQL programming. My database needs are fairly simple, but I am having
issues with some basic SQL statements that worked fine in Oracle
coming back with errors in H2.
I am creating an object database where H2 will be used to store object
JSON code and the meta data used to retrieve those objects. I want
every entry to have a unique numeric ID. In Oracle, I used a trigger
to pull the next value from a sequence and inserted that on insert.
My trigger looked as follows:
create trigger V_USERS_ID
before insert on V_USERS
for each row
begin
select ID_SEQ.NEXTVAL into :
NEW.ID from DUAL;
end
/
I suspect H2 doesn't use the DUAL table, so that piece is likely out,
but the bigger problem is that the syntax is requiring me to call come
sort of predefined class to replace my single line of SQL code I want
to run. Is there a way to program the above SQL directly in H2, or am
I stuck trying to figure out how to define and declare an external
class? If the latter, any pointer to documentation on how to go about
this would be greatly appreciated.
Failing either of the above, is there a simple way to implement an
automatically assigned unique numeric identifier to an ID field, one
which will overwrite any value included for that field in an insert
statement? I've looked at the UUID, but it seems like I'd need the
same sort of mechanism to insert a random UUID as I need to insert a
sequential ID.
Again, any pointers would be greatly appreciated.