liquibase / liquibase-hanadb

Liquibase extension for HANA
Apache License 2.0
7 stars 15 forks source link

TRIGGER is broken “when if end if" is using #156

Open tempbrucefu opened 1 year ago

tempbrucefu commented 1 year ago

Hello,

When running following statement as a single changeset, CREATE TRIGGER TRG_DO_DELETE BEFORE DELETE ON TABLE_TEST REFERENCING OLD ROW OLDROW FOR EACH ROW BEGIN IF :OLDROW.IS_DEFAULT = TRUE THEN DECLARE DELTABLE_TEST_ERROR CONDITION FOR SQL_ERROR_CODE 10002; DECLARE EXIT HANDLER FOR DELTABLE_TEST_ERROR RESIGNAL; SIGNAL DELTABLE_TEST_ERROR SET MESSAGE_TEXT = 'Cannot delete default'; END IF; END;

the syntax error will be reported and the script is parsed as "CREATE TRIGGER TRG_DO_DELETE BEFORE DELETE ON TABLE_TEST REFERENCING OLD ROW OLDROW FOR EACH ROW BEGIN IF :OLDROW.IS_DEFAULT = TRUE THEN DECLARE DELTABLE_TEST_ERROR CONDITION FOR SQL_ERROR_CODE 10002; DECLARE EXIT HANDLER FOR DELTABLE_TEST_ERROR RESIGNAL; SIGNAL DELTABLE_TEST_ERROR SET MESSAGE_TEXT = 'Cannot delete default'; END"

BTW, when more trigger creations are put into a single changeset, it will be not split into two stataments and syntax error will be reported which is similar to run when scripts including multiple trigger creations.