I have a table called base which I need to update after a record has been inserted. I have written a function.
CREATE OR REPLACE FUNCTION host_ip() RETURNS trigger AS $host_ip$
BEGIN
update base set thumbnail_url =
replace ("thumbnail_url",'localhost','myipadd') WHERE id = NEW.id;
RETURN NEW;
END;
$host_ip$ LANGUAGE plpgsql;
This function is giving me errors when a record is inserted. I have a trigger which calls the function after insert. The error is PL/pgSQL function host_ip() line 4 at SQL statement SQL statement
The trigger is:
CREATE TRIGGER host_ip AFTER INSERT OR UPDATE ON base
FOR EACH ROW EXECUTE PROCEDURE host_ip();