How can I run an external program from a stored procedure?

Started by Rob Richardsonalmost 16 years ago3 messagesgeneral
Jump to latest
#1Rob Richardson
Rob.Richardson@rad-con.com

Greetings!

I'm running PostgreSQL 8.4 on MS Windows Server 2003.

Assume I have a program named FlashLightAndSoundHorn.exe. In my
database, there is a table that is read by some other program. Records
in that table have a timestamp, so I can tell how long they've been
waiting. I want a stored procedure that checks to see if a record has
been waiting too long, and if it does, then it will run
FlashLightAndSoundHorn.exe. How do I run that program from inside a
stored procedure?

Thanks very much!

RobR

Robert D. Richardson
Product Engineer Software
<file:///t:/Sales/Images/Marketing%20Pictures/Logos/LOGOs%20from%2010th%
20Floor/RAD-CON%20Logo%20for%20Signature.jpg>
RAD-CON, Inc.
TECHNOLOGY: Innovative & Proven
Phone : +1.440.871.5720 ... ext 123
Fax: +1.440.871.2948
Website: www.RAD-CON.com <http://www.rad-con.com/&gt;
E-mail: rob.richardson@RAD-CON.com

Attachments:

Radcon icon.bmpimage/bmp; name="Radcon icon.bmp"Download+2-0
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Rob Richardson (#1)
Re: How can I run an external program from a stored procedure?

"Rob Richardson" <Rob.Richardson@rad-con.com> writes:

Assume I have a program named FlashLightAndSoundHorn.exe. In my
database, there is a table that is read by some other program. Records
in that table have a timestamp, so I can tell how long they've been
waiting. I want a stored procedure that checks to see if a record has
been waiting too long, and if it does, then it will run
FlashLightAndSoundHorn.exe. How do I run that program from inside a
stored procedure?

If you write in plperlu or plpythonu then you can use those languages'
ordinary ability to run a subprocess.

regards, tom lane

#3Steve Atkins
steve@blighty.com
In reply to: Rob Richardson (#1)
Re: How can I run an external program from a stored procedure?

On Jun 4, 2010, at 8:03 AM, Rob Richardson wrote:

Greetings!

I'm running PostgreSQL 8.4 on MS Windows Server 2003.

Assume I have a program named FlashLightAndSoundHorn.exe. In my database, there is a table that is read by some other program. Records in that table have a timestamp, so I can tell how long they've been waiting. I want a stored procedure that checks to see if a record has been waiting too long, and if it does, then it will run FlashLightAndSoundHorn.exe. How do I run that program from inside a stored procedure?

A better way to do it is to have an external program that polls the database (or waits to be notified from a database trigger using listen/notify) and have that program do anything that's needed.

Cheers,
Steve