31 May 2008

SQL: Calling Unix Commands from Oracle.

Sample Oracle Java Program to execute Unix Command/Shell Program from Oracle SQL

CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "ExecuteShellCommand" AS
package oracle.apps.cs;

import java.lang.*;
import java.sql.*;
import oracle.sql.*;
import java.io.*;

public class ExecuteShellCommand
{
public static void executeCommand (String command) throws IOException
{
String[] uFullCommand = {"/bin/sh", "-c", command};
Runtime.getRuntime().exec(uFullCommand);
}
};
/

No comments: