我想从Java调用Oracle的存储过程,但是execute()和executeUpdate()总是返回false。 此存储过程具有IN参数(rut),用于将映像(来自Oracle中创建的目录)放在临时表中。 基本上从Java来说,我必须调用存储过程并传递它参数。
============== Oracle ==============
create or replace PROCEDURE PS_OBT_POSTULANTE (P_RUT_POSTULANTE IN
VARCHAR2)
IS
V_TEMP_BLOB BLOB;
V_TEMP_BFILE BFILE;
V_EXISTE NUMBER(2);
V_FOTO VARCHAR(30);
BEGIN
--- INSERTAR FOTO EN EL REGISTRO
DBMS_LOB.CREATETEMPORARY(V_TEMP_BLOB,TRUE);
V_FOTO := P_RUT_POSTULANTE || '.PNG';
V_TEMP_BFILE := BFILENAME('DIR_LOB',V_FOTO);
V_EXISTE := dbms_lob.fileexists(V_TEMP_BFILE);
IF V_EXISTE = 1 THEN
DBMS_LOB.FILEOPEN(V_TEMP_BFILE, DBMS_LOB.FILE_READONLY);
DBMS_LOB.LOADFROMFILE(V_TEMP_BLOB,V_TEMP_BFILE,
SYS.DBMS_LOB.GETLENGTH(V_TEMP_BFILE));
INSERT INTO TEMP_PST (FOTO_PST)
VALUES(
V_TEMP_BLOB
);
DBMS_LOB.FILECLOSE(V_TEMP_BFILE);
END IF;
dbms_lob.freetemporary(V_TEMP_BLOB);
END PS_OBT_POSTULANTE;
============== JAVA ==============
public static boolean fillInfoPostBD(String rut) {
String query = "call PS_OBT_POSTULANTE("+rut+")";
try (Connection con = BD.Conexxxion.conectar()) {
try (CallableStatement cs = con.prepareCall(query)) {
if (cs.executeUpdate()>0) {
cs.close();
con.close();
return true;
}
}
} catch (SQLException e) {
Modelo.Control.error(null, "Error al consultar los datos del
postulante " + e);
return false;
}
}