I am trying to create a trigger function using Liqubase. Below is my change set:
<changeSet id="1" author="valen" dbms ="postgresql" >
<createProcedure>
CREATE OR REPLACE FUNCTION public.onupdate_update_mod_ver()
RETURNS trigger
LANGUAGE plpgsql
AS $function$
BEGIN
IF NEW <> OLD THEN
UPDATE mod_ver SET rec_change_date = current_timestamp where id = new.id;
END IF;
RETURN NEW;
END;
$function$;
</createProcedure>
<rollback>
DROP FUNCTION onupdate_update_mod_ver();
</rollback>
</changeSet>
It throws a syntax error on the line IF NEW <> OLD THEN
.
It says tag name expected
. Basically it reads <>
as a tag instead of "not equal".
I tried using !=
but didn't work.
Note: the function is correct when executed directly in the database, but with a change log it doesn't work. I also tried to use <sql>
tags to simply write it as statement but still same error.
Any idea how to bypass this issue?