我正在尝试在 Oracle 11g 中实现一个函数,该函数调用 java 类来解密 Blob 图像信息。
一切似乎都有效,但我收到 ORA-06553 PLS-306“参数数量或类型错误”
该函数接受一个 blob 并返回一个 blob,因此我看不到错误来自何处。
PL/SQL函数:
create or replace
function decrypt_image return blob as
language JAVA name 'Imageutil.decryptBlobImage (java.sqlBlob) return java.sqlBlob';
Java函数:
public class Imageutil
public static java.sql.Blob decryptBlobImage (java.sql.Blob img) throws Exception {
try {
int len = (int)img.length();
byte[] imagearray = img.getBytes(1, len);
byte[] decrypted = Encryptor.decryptBinary(imagearray);
Blob retval = new SerialBlob(decrypted);
return retval;
} catch (SQLException ex) {
ex.printStackTrace();
throw new Exception("Error handling blob",ex);
}
}
}
数据在表格中:
temp_image(id number, image blob, decrypted blob);
我正在努力
update temp_image set decrypted = decrypt_image(image);
当我收到错误时。每次都会生成一个Oracle trc文件,但似乎没有错误:
========= Dump for error ORA 1110 (no incident) ========
----- DDE Action: 'DB_STRUCTURE_INTEGRITY_CHECK' (Async) -----
(然后对数据库进行完整性检查)。
该函数有效,原始数据很长,我可以对数据进行十六进制转储并解密它。测试表是通过 to_lob() 函数在原始长原始数据上加载的。
最佳答案
PL/SQL 声明中似乎有 java.sqlBlob
而不是 java.sql.Blob
;但您也没有在该声明中为您的函数提供参数:
create or replace
function decrypt_image (original_blob blob) return blob as
language JAVA name 'Imageutil.decryptBlobImage (java.sql.Blob) return java.sql.Blob';
无论您的版本如何,PL/SQL 函数都不接受参数,因此当您将其调用为 decrypt_image(image)
时,您传递了错误数量的参数 - 它不期望任何参数,但您传递了一个。
关于java - ORA-06553 Oracle 中带有 Blob 的 java 函数参数错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28909622/