ORA-01465: 使用 BLOB 时 oracle 中的十六进制数无效

ORA-01465: invalid hex number in oracle while using BLOB

我正在用 oracle 11g 设计一个数据库。我设计了一个 table 字段,

CUST_ID, NUMBER(5) //this is a foreign key
Review, BLOB //to store big strings 
Date, SYSDATE

现在,当我尝试在 table 中插入数据时,例如-

insert into "ReviewTable" values ( 3, 'hello, this is the first review',SYSDATE)

它给出 [Err] ORA-01465:无效的十六进制数。 如果有人可以帮助我解决错误?

您将字符串转换为 BLOB,您可以通过包 utl_raw.cast_to_raw 或通过 to_clob('mystring') 将 varchar 转换为 clob 然后在代码中使用过程 DBMS_LOB.convertToBlob

但是如果您打算将字段用于字符串,为什么不将它们保存为 CLOB?

下面是 2 个带有 BLOB 和 CLOB 字段的示例

BLOB

create table ReviewTable( CUST_ID NUMBER(5)
,Review  BLOB  
,Dt Date);

insert into ReviewTable values ( 3, utl_raw.cast_to_raw('hello, this is the first review'),SYSDATE);

CLOB

create table ReviewTable2( CUST_ID NUMBER(5)
,Review  CLOB  
,Dt Date);

insert into ReviewTable2 values ( 3, 'hello, this is the first review',SYSDATE);