Solved

running external program inside plsql

Posted on 2004-08-24
1
845 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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 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

14 Experts available now in Live!

Get 1:1 Help Now