Question

When I migrate a Oracle Function to HSQLDB I need translate the "Select into" for HSQLDB. The Oracle script may look like:

CREATE FUNCTION getId()
RETURN NUMBER IS 
       temp_id NUMBER;
...

BEGIN
....    
  SELECT id id INTO temp_id from ( select id form ..... );

In HSQLDB 2.0.0, I can do the following:

 CREATE FUNCTION getId()
RETURNS BIGINT 
BEGIN ATOMIC 
  DECLARE temp_id BIGINT;
....

  SET temp_id = SELECT id id FROM ....

However, it doesn't work in HSQLDB 2.2.9 anymore. The error message is:

[CREATE - 0 row(s), 0.000 secs] [Error Code: -5608, SQL State: 42608] wrong or missing data impact clause in declaration: READS SQL in statement

From the release note of HSQLDB 2.2, it says they already support "select into", but I didn't find the way.

Anyone know how to do it in HSQLDB 2.2.9?

Was it helpful?

Solution

In 2.2.x series there are more strict data access checks. A routine that reads table data must be declared as such.

CREATE FUNCTION getId()
RETURNS BIGINT READS SQL DATA 
BEGIN ATOMIC 
  DECLARE temp_id BIGINT;
....

  SET temp_id = SELECT id id FROM ....

More enhancments and fixes have been introduced in recent months. It is better to use the latest snapshot jar (and version 2.3.0 when it is released) instead of 2.2.9.

http://www.hsqldb.org/repos/org/hsqldb/hsqldb/SNAPSHOT/

The snapshot directory is a Maven repository.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top