Home » SQL & PL/SQL » SQL & PL/SQL » Can Oracle PL/SQL call Shell Script / OS command
Can Oracle PL/SQL call Shell Script / OS command [message #1986] Fri, 14 June 2002 09:55 Go to next message
Pradeep Alurkar
Messages: 1
Registered: June 2002
Junior Member
Can We call OS commands or Shell script from Oracle PL/SQL? I want to write stored procedure which will call shell script on Unix server on which oracle is residing ..

Can it be done this way?
Re: Can Oracle PL/SQL call Shell Script / OS command [message #1994 is a reply to message #1986] Fri, 14 June 2002 13:03 Go to previous message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
i beleive,
You can use dbms_pipe ( for embedding the OS commands) or JavaStoredProcedure or Just libraries.
anyhow to execute such a procedure u need to make use of external procedures ( Pro*c etc.)

from the docs
create library ora_nt is 'C:ntshell1.dll'
/
create or replace function ntshell(cmdin varchar2, arg1 varchar2, arg2 varchar2) 
return binary_integer is 
external library ora_nt
name "exec"
language C
parameters (cmdin string, arg1 string, arg2 string);
/

#include<stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include<process.h>

__declspec(dllexport) exec(char *cmdin, char *arg1, char *arg2)
{
if(spawnlp(P_NOWAIT, cmdin, cmdin, arg1, arg2, NULL) == -1) return -1;
return 1;


and usage is
SQL> select ntshell('cmd.exe','/c','del c:sig.txt') from dual;

[Updated on: Mon, 28 December 2009 11:55]

Report message to a moderator

Previous Topic: Manipulation Function
Next Topic: Re: Extract numbers from a string
Goto Forum:
  


Current Time: Fri Apr 26 23:40:23 CDT 2024