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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Start a program from wthin Oracle

Re: Start a program from wthin Oracle

From: Rauf Sarwar <rs_arwar_at_hotmail.com>
Date: 29 Dec 2002 23:19:23 -0800
Message-ID: <92eeeff0.0212292319.171b0b9f@posting.google.com>


> I have done this with a java stored procedure. You don't need JNI. All
> you need to do is use the java runtime object. Just create the java
> stored procedure and call it as you would call any stored
> procedure. You can find details about this at Tom Kytes site (or in
> his book Expert one-on-one Oracle I think). Check out
>
> http://asktom.oracle.com
>
> Tim

Yes you can use Runtime object to execute an OS command. But using the Runtime object will render the true nature of java's platform independence obsolete.

This type of solution may be suitable for a home grown database or where the underlying OS will stay constant, *BUT* you may not use this solution for a commercial product unless you want to duplicate your OS commands/scripts across underlying platforms. Furthermore, what if database is migrated over to a different OS...then the server java code will have to be modified according to the OS before/after doing export and import...instead of *ONLY* rewriting the batch scripts. This to me is unnecessary overhead.

IMO, If the script needs to be prompted to extract data from the database on every insert/update/delete (as the OP wants to do), then why not move the batch script sql extract code into the server. Either use UTL_FILE package or Java's java.io interface to write stuff to a file on every insert/update/delete statements. Only use underlying batch/shell scripts (Run as cron job) to pick up data from the file/s and do stuff with it. This way everything resides in the database, which is consistent across different platforms + it is much safer rather then going out from Oracle to execute an OS command against the database.

Regards
/Rauf Sarwar Received on Mon Dec 30 2002 - 01:19:23 CST

Original text of this message

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