I want to execute a perl script at the click of a button in an application(Oracle Apex). The script I can place in the DB host which the app interacts with. In apex i can execute PL/SQL code. Is there a way by which I can execute the perl script using PL/SQL?
1 Answer
You can call Java from PL/SQL. With Java you can execute anything from the command line.
Random Example:
import java.sql.*;
import oracle.jdbc.driver.*;
public class Adjuster {
public static void raiseSalary (int empNo, float percent)
throws SQLException {
Connection conn = new OracleDriver().defaultConnection();
String sql = "UPDATE emp SET sal = sal * ? WHERE empno = ?";
try {
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setFloat(1, (1 + percent / 100));
pstmt.setInt(2, empNo);
pstmt.executeUpdate();
pstmt.close();
} catch (SQLException e) {System.err.println(e.getMessage());}
}
}
CREATE OR REPLACE PROCEDURE raise_salary (empno NUMBER, pct NUMBER)
AS LANGUAGE JAVA
NAME 'Adjuster.raiseSalary(int, float)';
Manual: http://docs.oracle.com/cd/B28359_01/java.111/b31225/chfive.htm