难题:关于更新表内记录的clob字段,分不够再加,帮顶也给分

yan63 2005-08-12 04:39:24
表A:
from_id( NUMBER) from_context( CLOB )
1 <long text>
2 <long text>
.....

表B
to_id( NUMBER) to_context( CLOB )
1 <long text>
3 <long text>
...

需求:以表A中的记录更新表B
即:INSERT INTO A ( from_id,from_context ) SELECT to_id,to_context FROM B where A.from_id = B.to_id,
但是clob类型字段报错,请问SQL该如何写?
若是SQL无法实现,可有什么替代的方法?
谢谢!

...全文
231 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
yan63 2005-08-16
  • 打赏
  • 举报
回复
njhart2003,waterfirer(水清)的是正解,
TO zengguochao1980(大地):我试了一下,INSERT INTO A ( from_id,from_context )的写法在oracle里会出错。
TO dbpointer(苞谷) :不好意思,我回得太慢了。
谢谢大家.
dbpointer 2005-08-15
  • 打赏
  • 举报
回复
搞定没有,总结一下啊
zengguochao1980 2005-08-15
  • 打赏
  • 举报
回复
将 INSERT INTO A ( from_id,from_context ) SELECT to_id,to_context FROM B where A.from_id = B.to_id
放到存储过程中试试
tommysun 2005-08-13
  • 打赏
  • 举报
回复
我是來接分的
yan63 2005-08-12
  • 打赏
  • 举报
回复
刚刚有事外出了一下
waterfirer 与 njhart2003() 的方法马上就试一下,可以的话马上结。
谢谢 nik_Amis(...) 帮顶!
yan63 2005-08-12
  • 打赏
  • 举报
回复
头晕了,这是追加的SQL
INSERT INTO A ( from_id,from_context ) SELECT to_id,to_context FROM B where A.from_id <> B.to_id
更新的SQL:UPDATE B SET B.to_id = A.from_id,B.to_context = A.from_context where A.from_id = B.to_id

问题是clob如此更新报错,请大侠不吝赐教。
nik_Amis 2005-08-12
  • 打赏
  • 举报
回复
up
njhart2003 2005-08-12
  • 打赏
  • 举报
回复
晕!没看清表名
更正
update B set from_context=(select to_context from A where A.from_id=B.to_id)
where exists (select 1 from A where A.from_id=B.to_id);


njhart2003 2005-08-12
  • 打赏
  • 举报
回复
update to_id
set to_context=(select from_context from from_id where from_id.id=to_id.id)
where exists (select 1 from from_id where from_id.id=to_id.id);
waterfirer 2005-08-12
  • 打赏
  • 举报
回复
update A set from_context=(select to_context from B where to_id=A.from_id);

17,377

社区成员

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

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