I am new to H2 and want help to convert the following MySql sequence to H2
sequence .
MySql 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
Java method calling the sequence:
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.");
}
}
please can anyone help me convert this to H2 and Java.
--
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.