Skip site navigation (1) Skip section navigation (2)

How to execute a system file in procedure?

From: Raymond Chui <raymond(dot)chui(at)noaa(dot)gov>
To: pgsql-general(at)postgresql(dot)org(dot)pgsql-sql(at)postgresql(dot)org
Subject: How to execute a system file in procedure?
Date: 2001-08-20 14:08:36
Message-ID: 3B8119E4.A5FDCA1F@noaa.gov (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-sql
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(at)host(dot)domain < `echo "It is time to re-index
the table"`



Responses

pgsql-sql by date

Next:From: Jeff EckermannDate: 2001-08-20 14:29:21
Subject: Re: Simple SQL-syntax
Previous:From: Fredrik ThunbergDate: 2001-08-20 11:15:33
Subject: Simple SQL-syntax

pgsql-general by date

Next:From: Fernando IparDate: 2001-08-20 15:00:51
Subject: WAL
Previous:From: Tom LaneDate: 2001-08-20 14:00:13
Subject: Re: database corruption on VACUUM ANALYZE, now unable to initdb

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group