How to call an external program
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: How to call an external program

Hybrid View

  1. #1
    Join Date
    Mar 2001
    Posts
    188

    Exclamation

    Hi gurus
    i have a simple question. Can i call an external program from an PL/SQL procedure.
    If yes. How can i make this. Can you give me a small example and which packages must be installed.

    our system runs under linux with the oracle enterprice edition 8.1.7.

    Thanks

    Regards
    Thomas Schmidt

    [Edited by tomate on 04-06-2001 at 02:13 AM]

  2. #2
    Join Date
    Jan 2001
    Posts
    153
    Hi

    First of all u havent mentioned the version u r using..anyway check this



    CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "Exec" AS
    import java.lang.Runtime;

    public class Exec {
    public static void ExecNT (String command) throws java.io.IOException {
    Runtime rt = java.lang.Runtime.getRuntime();
    String[] cmd = {"cmd", "/c", command};
    rt.exec(cmd);
    }
    }
    /
    CREATE OR REPLACE PACKAGE OS AS
    PROCEDURE ExecNT (command IN VARCHAR2);
    END;
    /
    CREATE OR REPLACE PACKAGE BODY OS AS
    PROCEDURE ExecNT (command IN VARCHAR2)
    AS LANGUAGE JAVA NAME 'Exec.ExecNT(java.lang.String)';
    END;


    Example
    ======

    BEGIN
    OS.ExecNT('copy c:\temp\t1.txt c:\temp\t2.txt');
    END;


    Requirements and limitations:
    ===================
    1. The package runs on Windows NT only. It might run on Windows 95/98/2000, but is not tested on these platforms.
    2. The Oracle server should be Oracle8i 8.1.5 or higher with JServer option installed.
    3. The user in which schema the package is installed should have the JAVAUSERPRIV and JAVASYSPRIV roles granted.

    Vijay.s

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width