Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Windows OS command from PL/SQL

3dsMar 3 2015 — edited Mar 4 2015

Hi all,

I am developing a proto app. I have Oracle 11gR2 standard edition 1 on Windows 8.1.

My requirement is execution of OS commands from PL/SQL. The PLSQLOSCOMMAND.zip fulfils all the requirements like ZIP file and LOB.

http://www.oracle.com/technetwork/database/enterprise-edition/calling-shell-commands-from-plsql-1-1-129519.pdf

Oracle PL/SQL executing OS Commands | SourceForge.net

1) First I run the install.sql script against my user ( STK_BIN ). This is having DBA role. No errors.

2) Logged in as SYS and run following commands :

     begin

     dbms_java.grant_permission( 'STK_BIN', 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'read,write,execute,delete' );

     commit;

     dbms_java.grant_permission( 'STK_BIN', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor','' );

     commit;

     dbms_java.grant_permission( 'STK_BIN', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor','' );

     commit;

     end;

3) select * from dba_java_policy shows

GRANT  STK_BIN  SYS   java.io.FilePermission   <<ALL FILES>>   read,write,execute,delete   ENABLED   151
GRANT  STK_BIN  SYS   java.lang.RuntimePermission   readFileDescriptor   ENABLED   152
GRANT  STK_BIN SYS  java.lang.RuntimePermission   writeFileDescriptor   ENABLED   153

4)  select * from table(file_pkg.get_file_list(file_pkg.get_file('\')));

Shows proper directory and file details

5) But when I run command,

select os_command.exec('mkdir STK_BIN_DIR') from dual;

It gives me error

ERROR at line 1:

ORA-29532: Java call terminated by uncaught Java exception:

java.io.IOException: Exception during creation of the process:

java.io.IOException: The handle is invalid.

ORA-06512: at "STK_BIN.OS_COMMAND", line 68

What I have done wrong. Why execution of any windows OS commands giving the error ?

This post has been answered by Billy Verreynne on Mar 4 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 1 2015
Added on Mar 3 2015
3 comments
2,312 views