在连接到 ORA DB 的 PHP 中,我最近解决了插入 CLOB 的问题,应该以同样的方式处理。
在我的情况下,将数据作为字符插入就足够了,而在绑定时我将字符长度设置为绑定长度。但是您可以尝试使用函数TO_BLOB(),它需要将输入转换为RAW:
INSERT INTO my_blob_table (my_blob_column) VALUES (TO_BLOB(UTL_RAW.CAST_TO_RAW('some binary data as string')))
或者通用的TO_LOB() 也应该可以工作(根据源/目标列转换为CLOB 或BLOB):
INSERT INTO my_blob_table (my_blob_column) VALUES (TO_LOB('some binary data as string'))
编辑:使用谷歌我发现这些应该可以工作:
- 如果我们想要将
long 列转换为 clob/blob:
create table t1 (id int, my_blob blob);
create table t2 (id int, my_long long);
insert into t2 values (1, rpad('*',4000,'*'));
insert into t1 select id, to_lob(my_long) from t2;
- 如果我们想要将
long raw 列转换为blob:
create table t1 (id int, my_blob blob);
create table t2 (id int, my_long_raw long raw);
insert into t2 values (1, rpad('*',4000,'*'));
insert into t1 select id, to_blob(my_long_raw) from t2;
应该可以...见here和here。