I need to creata a trigger:
CREATE OR REPLACE TRIGGER IS_PI_AFTER_UPDATE
AFTER UPDATE
ON USERS
FOR EACH ROW
DECLARE
BEGIN
IF (:OLD.IS_PI != :NEW.IS_PI) THEN
IF(:NEW.IS_PI = ‘true’) THEN
INSERT INTO PI_DELEGATES (PI_USER_ID, DELEGATE_USER_ID) VALUES (:NEW.USER_ID, :NEW.USER_ID);
ELSE
DELETE FROM PI_DELEGATES WHERE PI_USER_ID = :NEW.USER_ID AND DELEGATE_USER_ID = :NEW.USER_ID;
END IF;
END IF;
END
/
I tried various options, but it always complains about missing ; at the end. Can you please identify the problem.
This is the output:
Version:1.0 StartHTML:0000000149 EndHTML:0000019699 StartFragment:0000000199 EndFragment:0000019665 StartSelection:0000000199 EndSelection:0000019665 <span at end of SQL statement
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1608)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1343)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:194)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:470)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:355)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:347)
at liquibase.executor.jvm.JdbcExecutor$1ExecuteStatementCallback.doInStatement(JdbcExecutor.java:92)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)
… 9 more
FAILURE: Build failed with an exception.