我必须在 oracle 视图中插入 blob。在这种情况下,没有机会将此 EMPTY_BLOB() 与返回子句一起使用。像这样:“插入表(a,b,c)值(a,b,EMPTY_BLOB())将c返回:photo”因为返回不t work in views
I need a method to create empty blob before inserting data, but i don
知道如何使用PDO。
谢谢!
在连接到 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;