更新blob字段

ecjtuhr 2011-02-18 03:46:37
oracle数据库,有张表A,其中有个字段xx,类型为blob字段,,我想更新这个字段,
update a set xx=xx|| char_to_raw('aa') ,报错,其中,char_to_raw是我写的将字符转16进制函数,错误应该是出在接的问题,请教怎么将原来的这个字段接上转换后的数据更新成新的字段?
...全文
422 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
lindaozhi 2011-06-07
  • 打赏
  • 举报
回复
顶上去,我也遇到这个问题。
ecjtuhr 2011-02-26
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 lyiply 的回复:]
update a set xx=concat(xx, char_to_raw('aa'))
这样试试,,也是连接作用
[/Quote]
还是报上图所示错误!
lyiply 2011-02-26
  • 打赏
  • 举报
回复
update a set xx=concat(xx, char_to_raw('aa'))
这样试试,,也是连接作用
ecjtuhr 2011-02-25
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 zhuomingwang 的回复:]
SQL code

insert into t_blob values ('tom',utl_raw.cast_to_raw('tom is a good boy!'));

select stuname,utl_raw.cast_to_varchar2(dblob) from t_blob;

STUNAME
--------------------
UTL_RAW.CAST_T……
[/Quote]


还是报错
,我在存储过程中跟了下xx这个blob字段的值是open=F, temp=F, length=2735, chunksize=8132, data=5957303130313B59573031303130313B595730313031303130383B595730313031303130385F3334303B595730313031303130385F3331363B5957303130313031303830313B59573031303130313038303130313B59573031303130313038303130315F3334323B59573031303130313038303130315F3334333B59573031303130313038303130323B59573031303130313038303130325F3334343B59573031303130313038303130325F3334353B59573031303130313038303130333B59573031303130313038303130335F3334363B59573031303130313038303130335F3334373B59573031303130313038303130335F3330313B59573031303130,而我要在这个字段的基础上接上‘;99999’,所以用如下语句:
update A set xx= utl_raw.cast_to_raw(tempywrawdata||‘;99999’) ;其中tempywrawdata变量是varchar2(32767)类型,是通过tempywrawdata:=utl_raw.cast_to_varchar2(XX)转换后的,执行后就报图示错误,长度肯定是没有超过限制的吧。原来的长度是2735,加上转换‘;99999’应该也不会超长吧,怎么会报超长的错呢?请指教。

  • 打赏
  • 举报
回复

insert into t_blob values ('tom',utl_raw.cast_to_raw('tom is a good boy!'));

select stuname,utl_raw.cast_to_varchar2(dblob) from t_blob;

STUNAME
--------------------
UTL_RAW.CAST_TO_VARCHAR2(DBLOB)
----------------------------------------------------------------------------------------------------
tom
tom is a good boy!

Declare
b_c Blob;
Begin
select dblob Into b_c From t_blob For Update;
dbms_lob.append(b_c,utl_raw.cast_to_raw('and you?'));
Update t_blob
set dblob = b_c;
End;

--commit;

select utl_raw.cast_to_varchar2(dblob) from t_blob;

UTL_RAW.CAST_TO_VARCHAR2(DBLOB)
---------------------------------------------------------------------
tom is a good boy!and you?
CS_Planet_DN 2011-02-24
  • 打赏
  • 举报
回复
update table set a=utl_raw.cast_to_raw(utl_raw.cast_to_varchar2(a)||'tom is a good boy!');
ecjtuhr 2011-02-23
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 minitoy 的回复:]
2楼的不就可以了么?
[/Quote]
我试了下,不行啊,blob也能这样接?
Rotel-刘志东 2011-02-21
  • 打赏
  • 举报
回复
[code=SQ]update a set xx=xx|| utl_raw.cast_to_raw('aa')[/code]
minitoy 2011-02-21
  • 打赏
  • 举报
回复
2楼的不就可以了么?
ecjtuhr 2011-02-20
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 zhuomingwang 的回复:]
引用 4 楼 ecjtuhr 的回复:
引用 3 楼 zhuomingwang 的回复:
引用 1 楼 zhuomingwang 的回复:
SQL code
--这样试试
update a set xx=xx|| utl_raw.cast_to_raw('aa')


SQL code

--估计要改下 ||这个应该是对字符型有效的
update a set xx=utl_r……
[/Quote]

10G的版本
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 ecjtuhr 的回复:]
引用 3 楼 zhuomingwang 的回复:
引用 1 楼 zhuomingwang 的回复:
SQL code
--这样试试
update a set xx=xx|| utl_raw.cast_to_raw('aa')


SQL code

--估计要改下 ||这个应该是对字符型有效的
update a set xx=utl_raw.cast_to_raw(utl_ra……
[/Quote]
什么版本的oracle?
ecjtuhr 2011-02-18
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 zhuomingwang 的回复:]
引用 1 楼 zhuomingwang 的回复:
SQL code
--这样试试
update a set xx=xx|| utl_raw.cast_to_raw('aa')


SQL code

--估计要改下 ||这个应该是对字符型有效的
update a set xx=utl_raw.cast_to_raw(utl_raw.cast_to_varchar2(xx)||……
[/Quote]

报超长的错,见图
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 zhuomingwang 的回复:]
SQL code
--这样试试
update a set xx=xx|| utl_raw.cast_to_raw('aa')
[/Quote]

--估计要改下 ||这个应该是对字符型有效的
update a set xx=utl_raw.cast_to_raw(utl_raw.cast_to_varchar2(xx)||'aa')
cyousor 2011-02-18
  • 打赏
  • 举报
回复
Create Table t111(a Blob);
Insert Into t111 Values(Hextoraw('aa'));

Declare
c Blob;
Begin
select a Into c From t111 For Update;
dbms_lob.append(c,Hextoraw('bb'));
Update t111
set a = c;
End;
  • 打赏
  • 举报
回复
--这样试试
update a set xx=xx|| utl_raw.cast_to_raw('aa')

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧