I am very new to H2 and I went through some of the documents but I still
cannot convert the following MySql sequence to H2 sequence.
in MySql I have the following sequence:
CREATE DEFINER=`root`@`localhost` FUNCTION `PK_SEQUENCE`() RETURNS int(11)
BEGIN
DECLARE sequence_val INTEGER;
insert into PK_SEQUENCE values (NULL);
SELECT LAST_INSERT_ID() INTO sequence_val;
-- delete from sequence;
return sequence_val;
END
In the Java code I use the following :
public class PKSequenceService
{
public static int getPKSequence(EJFrameworkConnection connection)
{
EJStatementExecutor executor = new EJStatementExecutor();
List<EJSelectResult> results = executor.executeQuery(connection,
"SELECT PK_SEQUENCE() AS ID");
for (EJSelectResult result : results)
{
Object itemValue = result.getItemValue("ID");
if (itemValue instanceof Integer)
{
return ((Integer) itemValue).intValue();
}
}
throw new RuntimeException("Can not create PKSequence.");
}
}
In the database I have a table named "PK_SEQUENCE()". CAN ANY ONE HELP ME
TO CONVERT THIS sequence in to H2 sequence ?
The basic thing I does is use this sequence to generate the next integer
when called from the Java code.
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/groups/opt_out.