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 –