Como ejecutar SQLLDR desde un PL/SQL
Cual es la funci贸n que homologa en PL/SQL el funcionamiento de la funci贸n host( ) en forms,.
Como se hace para ejecutar el sqlldr desde un procedimiento almacenado PL/SQL.
Como se hace para ejecutar el sqlldr desde un procedimiento almacenado PL/SQL.
Comandos del S.O. no se pueden ejecutar desde PL-SQL, al menos de un manera tan obvia como hacer una llamada a HOST desde el sql-plus 贸 desde forms.
Tienes que utilizar Java
Tienes que utilizar Java
Hola
Yo he usado una funcion java compilada en la BD para ejecutar comandos D.O.S. (Esto lo saque del Metalink de Oracle) no todos los comandos funcionan correctamente, pero lo que puedes hacer es un .BAT que haga el loader y llamas con esta funcion el .bat desde la BD.
Un poco de vueltas para hacerlo pero funciona, al menos con 8.1.7 sobre windows 2.000
Espero te sirva de algo
CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "OSCommand" AS
import java.io.*;
public class OSCommand{
public static String Run(String Command){
try{
Runtime.getRuntime().exec(Command);
return("0");
}
catch (Exception e){
System.out.println("Error running command: " + Command +
"n" + e.getMessage());
return(e.getMessage());
}
}
}
/
/***************************/
CREATE or REPLACE FUNCTION OSCommand_Run(Command IN STRING)
RETURN VARCHAR2 IS
LANGUAGE JAVA
NAME 'OSCommand.Run(java.lang.String) return int';
/
/****************************/
--
-- EJECUTAR COMO SYS --
--
/****************************/
Execute dbms_java.grant_permission( '<USUARIO>','SYS:java.io.FilePermission','<<ALL FILES>>','execute');
execute dbms_java.grant_permission( '<USUARIO>','SYS:java.lang.RuntimePermission','writeFileDescriptor','*' );
execute dbms_java.grant_permission( '<USUARIO>','SYS:java.lang.RuntimePermission','readFileDescriptor','*' );
/****************************/
grant JAVASYSPRIV to <USUARIO>
/
exec call dbms_java.grant_permission('<USUARIO>','java.lang.RuntimePermission','loadLibrary.*',null);
/
--
-- Esta es la forma de llamarlo
--
DECLARE
x Varchar2(2000);
Begin
x := OSCommand_Run('d:/scripts/comando.bat');
DBMS_OUTPUT.Put_Line(x);
End;
Yo he usado una funcion java compilada en la BD para ejecutar comandos D.O.S. (Esto lo saque del Metalink de Oracle) no todos los comandos funcionan correctamente, pero lo que puedes hacer es un .BAT que haga el loader y llamas con esta funcion el .bat desde la BD.
Un poco de vueltas para hacerlo pero funciona, al menos con 8.1.7 sobre windows 2.000
Espero te sirva de algo
CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "OSCommand" AS
import java.io.*;
public class OSCommand{
public static String Run(String Command){
try{
Runtime.getRuntime().exec(Command);
return("0");
}
catch (Exception e){
System.out.println("Error running command: " + Command +
"n" + e.getMessage());
return(e.getMessage());
}
}
}
/
/***************************/
CREATE or REPLACE FUNCTION OSCommand_Run(Command IN STRING)
RETURN VARCHAR2 IS
LANGUAGE JAVA
NAME 'OSCommand.Run(java.lang.String) return int';
/
/****************************/
--
-- EJECUTAR COMO SYS --
--
/****************************/
Execute dbms_java.grant_permission( '<USUARIO>','SYS:java.io.FilePermission','<<ALL FILES>>','execute');
execute dbms_java.grant_permission( '<USUARIO>','SYS:java.lang.RuntimePermission','writeFileDescriptor','*' );
execute dbms_java.grant_permission( '<USUARIO>','SYS:java.lang.RuntimePermission','readFileDescriptor','*' );
/****************************/
grant JAVASYSPRIV to <USUARIO>
/
exec call dbms_java.grant_permission('<USUARIO>','java.lang.RuntimePermission','loadLibrary.*',null);
/
--
-- Esta es la forma de llamarlo
--
DECLARE
x Varchar2(2000);
Begin
x := OSCommand_Run('d:/scripts/comando.bat');
DBMS_OUTPUT.Put_Line(x);
End;
Ejecute correctamente todas las lineas, pero al ejecutar: exec call dbms_java.grant_permission(\'<USUARIO>\',\'java.lang.RuntimePermission\',\'loadLibrary.*\',null);
Me da el siguiente error:
BEGIN call dbms_java.grant_permission(\'CIAMSA\',\'java.lang.RuntimePermission\',\'loadLibrary.*\',null);
*
ERROR at line 1:
ORA-06550: line 1, column 12:
PLS-00103: Encountered the symbol "DBMS_JAVA" when expecting one of the following:
:= . ( @ % ;
The symbol ":=" was substituted for "DBMS_JAVA" to continue.
Que puede ser....
Me da el siguiente error:
BEGIN call dbms_java.grant_permission(\'CIAMSA\',\'java.lang.RuntimePermission\',\'loadLibrary.*\',null);
*
ERROR at line 1:
ORA-06550: line 1, column 12:
PLS-00103: Encountered the symbol "DBMS_JAVA" when expecting one of the following:
:= . ( @ % ;
The symbol ":=" was substituted for "DBMS_JAVA" to continue.
Que puede ser....
