Oracle,如何在查询的BLOB中插入LONG RAW(十六进制字符串比32767长得多)



对于十六进制字符串<=32767我做:

DECLARE buf RAW(32767);
BEGIN
buf := hextoraw('3082560E3082488E1B02....');
INSERT INTO FINGERPRINT VALUES ('bff17a2c-49b7-4d6c-9c4e-56cb1d35c8c8', '00003', 2, buf, NULL);
END;

如果字符串长度超过32767,该如何执行相同的操作?我尝试使用LONG RAW而不是RAW(32767(,但出现错误:

Error report -
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at line 1
06502. 00000 -  "PL/SQL: numeric or value error%s"
*Cause:    An arithmetic, numeric, string, conversion, or constraint error
occurred. For example, this error occurs if an attempt is made to
assign the value NULL to a variable declared NOT NULL, or if an
attempt is made to assign an integer larger than 99 to a variable
declared NUMBER(2).
*Action:   Change the data, how it is manipulated, or how it is declared so
that values do not violate constraints.

引用asktom:

在Oracle8i 8.0及更高版本中,不应使用LONG RAW。提供LONG和LONG RAW只是为了向后兼容——它们都是不推荐使用的数据类型。你应该使用blob

如果它仍然产生错误,请尝试使用:

  • dbms_lob.createtemporary

然后

  • dbms_lob.append

最新更新