Solved

running external program inside plsql

Posted on 2004-08-24
1
854 Views
Last Modified: 2008-03-03
Hi all,

Is there a way to run an external executable, a CGI, a bash script  for exanple inside plpgsql function/trigger ?

What I need is:
- When a function is executed,
inside function I want to execute an outside script with parameter[s]
i.e. :  /usr/bin/test  alo hello

is it possible ? ( no return required in fact)

thanks.
0
Comment
Question by:Ege
1 Comment
 
LVL 9

Accepted Solution

by:
rjkimble earned 250 total points
ID: 11882865
It appears that the answer to your question is no. From the PostgreSQL 7.4.1 documentation, chapter 36. Procedural Languages:

3. The PL must be declared with the command

CREATE [TRUSTED] [PROCEDURAL] LANGUAGE language-name
    HANDLER handler_function_name;

The optional key word TRUSTED specifies that ordinary database users that have no superuser privileges should be allowed to use this language to create functions and trigger procedures. Since PL functions are executed inside the database server, the TRUSTED flag should only be given for languages that do not allow access to database server internals or the file system. The languages PL/pgSQL, PL/Tcl, and PL/Perl are considered trusted; the languages PL/TclU, PL/PerlU, and PL/PythonU are designed to provide unlimited functionality and should not be marked trusted.

The key point is that PL/pgSQL is TRUSTED, and that implies that you won't be able to run an outside script. I suspect that you'll have to use an untrusted version of PL/Perl or PL/Python, although further reading indicates that Perl might not work, because it can't be used for trigger functions. From the manual, it appears to me that PL/Python should work. I have no experience with PL/Python, however, so I can't offer any expertise in that area.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Best database to use for Maps is PostgreSQL. This is an open source database. Comes as a package with most Linux OS. For more info visit the following site: http://www.postgresql.org/ (http://www.postgresql.org/) This requires some add-o…
Many developers have database experience, but are new to PostgreSQL. It has some truly inspiring capabilities. I have several years' experience with Microsoft's SQL Server. When I began working with MySQL, I wanted a quick-reference to MySQL (htt…
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now