問題描述
ORA‑01465: 使用 BLOB 時,oracle 中的十六進制數無效 (ORA‑01465: invalid hex number in oracle while using BLOB)
我正在用 oracle 11g 設計一個數據庫。我設計了一個帶有字段的表,
CUST_ID, NUMBER(5) //this is a foreign key
Review, BLOB //to store big strings
Date, SYSDATE
現在當我嘗試在表中插入數據時,例如‑
insert into "ReviewTable" values ( 3, 'hello, this is the first review',SYSDATE)
它給出 [Err] ORA‑01465: invalid hex number . 如果有人可以幫助我解決錯誤?
參考解法
方法 1:
you cast your string into BLOB, you can do this via package utl_raw.cast_to_raw
or convert varchar to clob via to_clob('mystring')
and then use procedure DBMS_LOB.convertToBlob
in your code
but if you are going to use the fields for string why don`t save them as a CLOB?
Here are 2 examples below with BLOB and CLOB fields
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);
(by Nasif Imtiaz Ohi、are)