Sql – PostgreSQL: operator does not exist: timestamp without time zone == timestamp without time zone

datetimepostgresqlsql

I have created below trigger and function for update on function where I want to exclude trigger execution when there are update on two columns 'frm' and 'upto' which are of type "timestamp without time zone"

In trigger function I am checking for updates on these two columns

CREATE OR REPLACE FUNCTION ff() RETURNS TRIGGER AS $$
BEGIN 
    if((old."frm" == New."frm") and (old."upto" == New."upto") ) then
        insert into TG_TABLE_NAME (select * from inserted );
        New."from" := old."from"; 
        NEW."upto" := current_timestamp;
        RETURN NEW; 
    END IF;
    RETURN NULL;
 END $$ LANGUAGE plpgsql;

create trigger update_trig2 after update on dd 
for each row execute procedure ff();`

After running update query i am getting below error in postgreSQL

ERROR: operator does not exist: timestamp without time zone == timestamp without time zone

Best Answer

The comparison operator is = in SQL and PL/pgSQL.

So you need to replace == with =