?
Solved

running external program inside plsql

Posted on 2004-08-24
1
Medium Priority
?
882 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 9

Accepted Solution

by:
rjkimble earned 1000 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

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…
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

770 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