Skip to Main Content
  • Questions
  • Executing OS commands from Oracle XE (Windows)

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Andy.

Asked: June 09, 2009 - 5:03 am UTC

Last updated: May 27, 2010 - 3:30 pm UTC

Version: 10.2.0.1.0

Viewed 1000+ times

You Asked

Hi Tom,

I am using Oracle Database 10g Express Edition Release 10.2.0.1.0 on Windows.

I have a requirement to call a batch script on the operating system from PL/SQL, passing it two parameters; a "source directory" and "destination directory".

The batch script will zip all the files in the source directory and copy the created zip file into the destination directory.

I think the normal solution to this problem is to use a Java program:

http://asktom.oracle.com/pls/asktom/f?p=100:11:979536059849863::::P11_QUESTION_ID:952229840241

But Oracle XE does not support Java stored procedures. is there another way to do this from PL/SQL?

If not, I guess one solution would be to write a CGI program to do the zip/copy and and call it from PL/SQL using UTL_HTTP. Not very elegant though!

Thanks for the time and effort you put into ask Tom, it really is the most useful and valuable Oracle resource on the web.

Andy.

and Tom said...

dbms_scheduler can be used to execute OS scripts in 10g and above

http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:16212348050#39092679158568

Rating

  (2 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Thanks & follow up information

Andy Sims, June 10, 2009 - 11:45 am UTC

Thanks Tom,

The solution you pointed me to works fine, thanks for taking the time to look at my problem. A couple of points for others who may end up looking at this solution:

The Windows service OracleJobSchedulerXE needs to be started.

As system user:
grant create external job to <USERNAME>;
grant create job to <USERNAME>;

Then once logged in as <USERNAME>

dbms_scheduler.create_job(
job_name=>'TEST_OS_EXEC_111',
job_type=>'executable',
job_action=>'C:\WINDOWS\system32\cmd.exe /c D:\20_OS\test1.bat',
enabled=>TRUE
);

Runs the batch file.

Ready to move on to "Standard Edition 1"

Andy Sims, May 27, 2010 - 2:49 pm UTC

Hi Tom, I understand you may delete this if you do not think its relevant! The customer who was using Oracle Express had it installed on a machine with 4 processors (Oracle Express would only use one of these of course). They are now ready to move up to a real licence, the next step being Standard Edition One. However, as far as I can tell, they would not be allowed to install Standard Edition One on this 4 processor machine as it has more than two sockets, have I got this right? To me it makes sense to me that you should be able to upgrade through the Oracle DB product stack without having to change hardware for each upgrade, but this does not seem to be the case. Any thoughts much appreciated.
Tom Kyte
May 27, 2010 - 3:30 pm UTC

Andy,

sorry, I cannot answer that one - it is more of a license question than a technology question all in all. I'm not sure what the restriction there is.

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library