Can you help me please with this problem? I need rewrite this simply trigger from sqlite to PostgreSQL format:
In sqlite:
CREATE TRIGGER connections_INSERT_update_connection_root_trg
AFTER INSERT ON dionaea.connections
FOR EACH ROW
WHEN
new.connection_root IS NULL
BEGIN
UPDATE connections SET connection_root = connection WHERE connection = new.connection AND new.connection_root IS NULL;
END;
I have tried this:
CREATE FUNCTION dionaea.connections_INSERT_update_connection_root_trg() RETURNS TRIGGER AS '
BEGIN
UPDATE connections SET connection_root = connection WHERE connection = new.connection AND new.connection_root IS NULL;
END
' LANGUAGE plpgsql;
It is correctly accepted.
CREATE TRIGGER connections_INSERT_update_connection_root_trg
AFTER INSERT ON dionaea.connections
FOR EACH ROW
WHEN
NEW.connection_root IS NULL
EXECUTE PROCEDURE dionaea.connections_INSERT_update_connection_root_trg();
After this I get this error:
NEW.connection_root IS NULL
Where is the problem please?