I would like execute a system command or my program or my shell
script in procedure. How do I do that?
For example,
CREATE FUNCTION myname() RETURN OPAQUE AS '
BEGIN
IF count(NEW.aColumn) >= 600
THEN RAISE EXCEPTION ''Hello, it is time to re-index the
table.'';
END IF;
RETURN NEW;
END; '
LANGUAGE 'plpgsql';
CREATE TRIGGER AFTER INSERT OR UPDATE ON mytable
FOR EACH ROW EXECUTE PROCEDURE myname();
But I prefer to execute a system command like mail
mail -s "Re-Index" system@host.domain < `echo "It is time to re-index
the table"`