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.