user2083529
user2083529

Reputation: 735

SELECT UUID() in HSQLDB

Does anyone know how to retrieve UUID via HSQLDB.

For example when i try

SELECT UUID();

via MYSQL it works fine. But the same statement doesn't work with HSQLDB. The following methods achieve the corresponding purpose

VALUES (UUID())

CALL(UUID())

SELECT UUID() FROM (VALUES(0)) t;

Is there a way which is same for mysql and hsqldb? HSQL doc says that UUID has been activated. http://hsqldb.org/doc/guide/builtinfunctions-chapt.html

Thanks.

Upvotes: 0

Views: 705

Answers (2)

fredt
fredt

Reputation: 24352

Turn on the MySQL compatibility mode in HSQLDB and it will allow your SELECT statement:

http://hsqldb.org/doc/2.0/guide/compatibility-chapt.html#coc_compatibility_mysql

Upvotes: 2

Raymond Nijland
Raymond Nijland

Reputation: 11602

Is there a way which is same for mysql and hsqldb?

Only way i can think off.
Create a table DUAL in HSQLDB

CREATE TABLE DUAL (
  id INT
);

So you can use

SELECT UUID() FROM DUAL LIMIT 1;

Then the query should work the same in both MySQL and HSQLDB.
DUAL in MySQL is a non existing dummy table.

Upvotes: 1

Related Questions