Received: from postgresql.org.org (webmail.postgresql.org [216.126.85.28]) by postgresql.org (8.11.3/8.11.4) with SMTP id f7KHkHP13377 for ; Mon, 20 Aug 2001 13:46:17 -0400 (EDT) (envelope-from pgsql-general-owner@postgresql.org) Received: from news.tht.net (news.hub.org [216.126.91.242]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f7KEXDP37569; Mon, 20 Aug 2001 10:33:13 -0400 (EDT) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.4/8.11.4) id f7KEPWF31984; Mon, 20 Aug 2001 10:25:32 -0400 (EDT) (envelope-from news) From: Raymond Chui X-Newsgroups: comp.databases.postgresql.general,comp.databases.postgresql.sql Subject: How to execute a system file in procedure? Date: Mon, 20 Aug 2001 10:08:36 -0400 Organization: Department of Commerce/NOAA/NWS Lines: 23 Message-ID: <3B8119E4.A5FDCA1F@noaa.gov> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.75 [en] (Win98; U) X-Accept-Language: en To: pgsql-general@postgresql.org.pgsql-sql@postgresql.org X-Archive-Number: 200108/594 X-Sequence-Number: 13949 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"`