0
begin
update table set value_blob = empty_blob()
where expr_id = 2
returning value_blob into :fileData;
update table set value_text = 'test'
where expr_id = 2;
end;
存储在文件中的PL/SQL代码。我想执行这个过程,并通过另一个文件中,:FILEDATA参数:
public void handle(String connectionString, String procedure, byte[] dataFile) throws Exception {
OracleDataSource ods = new OracleDataSource();
ods.setURL(connectionString);
try(Connection conn = ods.getConnection();
CallableStatement statement = conn.prepareCall(procedure);
InputStream inputStream = new ByteArrayInputStream(dataFile)) {
statement.setBinaryStream("fileData", inputStream, dataFile.length);
statement.executeUpdate();
} catch (Exception e) {
throw e;
}
}
执行后我有“测试”在value_txt列值,但在value_blob列中没有数据。此列中的以前的数据已更改为空blob。我试过命名和编号的参数,我确信dataFile字节数组不是空的。
我不相信它能够以这种方式工作,你的程序应该存储在你的数据库,那么你就可以使用CallableStatement的调用它https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_6009.htm –