SQL*Plus: Release 10.1.0.2.0 - Production on Mon Dec 5 18:07:21 2005 Copyright (c) 1982, 2004, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.1.0.3.1 - Production With the Partitioning, OLAP and Data Mining options SQL> CREATE OR REPLACE JAVA SOURCE NAMED "SqlLoaderExample" AS 2 public class SqlLoaderExample { 3 public static String run(String ctlFile) { 4 try { 5 String[] args = new String[3]; 6 args[0]="/usr/oracle/10ginfra/bin/sqlldr"; 7 args[1]="edm_user/edm_user@orcl"; 8 args[2]="CONTROL="+ctlFile; 9 Process process = Runtime.getRuntime().exec(args); 10 process.waitFor(); 11 return ""+process.exitValue(); 12 } 13 catch(Exception e) { return e.toString(); } 14 } 15 }; 16 / Java created. SQL> CREATE OR REPLACE FUNCTION example_run(ctlfile in varchar2) return varchar2 2 AS LANGUAGE JAVA NAME 'SqlLoaderExample.run(java.lang.String) return java.lang.String'; 3 / Function created. SQL> conn /as sysdba; Connected. SQL> begin 2 dbms_java.grant_permission('EDM_USER', 'java.io.FilePermission', '/usr/oracle/10ginfra/bin/sqlldr','execute'); 3 dbms_java.grant_permission('EDM_USER', 'java.lang.RuntimePermission', 'writeFileDescriptor', ''); 4 dbms_java.grant_permission('EDM_USER', 'java.lang.RuntimePermission', 'readFileDescriptor', ''); 5 end; 6 / PL/SQL procedure successfully completed. SQL> conn edm_user/edm_user@orcl Connected. SQL> var xx varchar2(100); SQL> exec :xx := example_run('/usr/tempfolder/VBAKDEMO.CTL'); BEGIN :xx := example_run('/usr/tempfolder/VBAKDEMO.CTL'); END; * ERROR at line 1: ORA-03113: end-of-file on communication channel