I am trying to write a trigger that executes after the INSERT completes on only newly inserted rows (I do not need to execute on old rows). The trigger should modify inserted string using split_part and replace functions.
The queries are as follows:
DROP TRIGGER IF EXISTS date_extraction ON t32upb
drop function if exists date_extraction();
CREATE FUNCTION date_extraction() RETURNS trigger AS $$
begin
NEW.filename := replace(split_part(old.filename,'_', 2), '.tif', '');
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER
date_extraction
AFTER INSERT on
sentinel_2.t32upb
FOR EACH STATEMENT EXECUTE PROCEDURE
date_extraction();
What is wrong with the query? it is not working