Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: PL/SQL calling external procedures

Re: PL/SQL calling external procedures

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 15 Jan 2002 11:10:37 -0800
Message-ID: <a21urd01cne@drn.newsguy.com>


In article <1011116118.232525_at_adsl.fast.net.uk>, "Jeremy says...
>
>
>"Thomas Kyte" <tkyte_at_us.oracle.com> wrote in message
>news:a2037l0lor_at_drn.newsguy.com...
>> In article <1011037625.323292_at_adsl.fast.net.uk>, "Jeremy says...
>> >
>> >Hello, I am aware of the ability to call o/s processes as an external
>> >procedure.
>> >
>> >What I would like to be able to do is execute a program on the server but
>> >initiated by pl/sql procedure - does the external procedure have to be
>> >written in 'c' (as I believe is the case) or could one call e.g. a shell
>> >script (as I am hoping but not betting on it!)
>> >
>> >thanks folks
>> >
>> >
>> >--
>> >Jeremy
>> >
>> see
>>
>http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:952229840
>241
>> for another way to do it.
>>
>> external procedures in C are written in C, you would have to write a small
>bit
>> of C (or java as the above shows) to accomplish this.
>>
>
>Hi
>
>I followed the example shown there and that's implemented on my system no
>problem. I then tried to substitute a shell command instead of the 'ps -ef'
>however when I run it with my command
>
>17:09:01 SQL> exec rc('/export/home/oracle/testdocs/textext.sh');
>PL/SQL procedure successfully completed.
> real: 60
>17:09:31 SQL>
>
>It doesn't actually do anything though. Permissions are set on the script to
>755 and it executes ok from within a normal shell.
>
>If I misspell the script name I get a Java error message
>(java.security.AccessControlException:) so it seems that some of what I have
>done is correct.
>
>Clearly I have a gap in my knoweledge here and could do with some help. It
>still wasn't clear to me whether the remote proc has to be a 'c' or java
>program or whether a shell script (basically something the o/s can execute)
>is OK - if the former, then I presume that is why I am unsuccessful in
>making the above work.
>
>Thanks...
>Jeremy
>
>

run /usr/bin/env or some other program that dumps the environment. This stuff will be running in a very different envionrment then the command line will be.

If using net8 to connect -- the environment will be partially inherited from the tns listener, if using a direct fork/exec with a dedicated server on the same box -- it will inherit part of your environment. I've had problems in that regards (it actually ran the script but it was totally messed up due to USER and other things being set wrong)

I've done this however -- running a shell script, it works once you get the environment going properly.

--
Thomas Kyte (tkyte@us.oracle.com)             http://asktom.oracle.com/ 
Expert one on one Oracle, programming techniques and solutions for Oracle.
http://www.amazon.com/exec/obidos/ASIN/1861004826/  
Opinions are mine and do not necessarily reflect those of Oracle Corp 
Received on Tue Jan 15 2002 - 13:10:37 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US