Using HSQLDB v2.7.2.
If I create a table and then a Before Update Trigger on that table with logic and compound statements I can only get the trigger to deploy alone as only DDL statement in the HyperSQL Database Manager. I cannot get the trigger to deploy in a sql file with HyperSQL SQLTool or using other SQL tool with same JDBC driver such as DBeaver SQL.
I can then see the trigger deployed with HyperSQL Database Manager Management in DBeaver SQL tool.
Seems like SQLTool and DBeaver do not like the statement seperator semicolon in the trigger but can't find a way to ahve them use a different separator for the DDL statements like can be done in other DBMS.
According to this posting (Trigger Syntax on HsqlDB : expected ;) it seems like this can be addressed in JavaScript or code but how can I change the Seperator in an SQL file or in the SQLTool, etc. I can't find in documenation.
SQL file:
DROP TABLE TEST2 IF EXISTS;
CREATE TABLE TEST2 (
ID NUMERIC (38) NOT NULL GENERATED BY DEFAULT AS IDENTITY(START WITH 1, INCREMENT BY 1 ) ,
STATUS NUMERIC (10) DEFAULT 1 ,
STARTTIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP ,
MODIFYTIME TIMESTAMP,
ENDTIME TIMESTAMP );
CREATE TRIGGER TEST2_BUPD_TRG
BEFORE UPDATE ON TEST2
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
BEGIN ATOMIC
SET NEW.MODIFYTIME = CURRENT_TIMESTAMP;
IF (NEW.STATUS = 9 AND
(OLD.STATUS IS NULL OR OLD.STATUS <> NEW.STATUS))
THEN
SET NEW.ENDTIME = CURRENT_TIMESTAMP;
END IF;
END;
The Error from SQLTool:
Error from SQLTool run on SQL file in command Dec 01, 2023 8:00:10 PM org.hsqldb.cmdline.SqlTool objectMain SEVERE: SQL Error at 'file:my.sql' line 4846: "CREATE TRIGGER BCHS_BUPD_TRG BEFORE UPDATE ON PUBLIC.DMKR_ASLINE.BCHS REFERENCING NEW AS NEW FOR EACH ROW BEGIN ATOMIC SET NEW.BCHMODIFYTIME = CURRENT_TIMESTAMP" unexpected end of statement : required: ; : line: 5 org.hsqldb.cmdline.SqlTool$SqlToolException
Error from DBeaver DB tool: SQL Error [42590]: unexpected end of statement : required: ; : line: 11