我必须在oracle视图中插入blob。在这种情况下,没有机会将此 EMPTY_BLOB() 与返回子句一起使用。喜欢这个:"在表 (a,b,c) 中插入值 (a,b, EMPTY_BLOB()) 将 c 返回到 :p hoto"Becouse RETURING 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'))
编辑:使用谷歌,我发现这些应该有效:
- 如果我们有一个要转换为
clob/blob
的long
列:
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;
- 如果我们有一个要转换为
blob
的long raw
列:
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;
这应该可以...看这里和这里。