oracle declare 问题

EncoreDw 2012-04-14 04:50:52
问题是: 一个表里面,有一万条数据。在表里面有一个属性,列如(temp) 属性。
temp的数据为 1, 2, 3, 4, 这样平均循环。
现在要更新成(temp的数据为 1, 2, 3, 4, 这样平均循环。)数据。。

求大侠, 好好想想,,,求求
...全文
268 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
ssqtjffcu 2012-04-15
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 的回复:]
z这里面 这几个是死的,修改的是条件。。。


update tables set = '1' where (活儿)

update tables set ='2' where (活得)

update tables set ='3 ' where ....

update tables set ="4" where ...
[/Quote]
楼主啊。。。你描述问题描述的真太那个了,看不懂,你一开始说1,2,3,4,5,6..............。现在改成 1,2,3,4,;1,2,3,4,;现在又变成这样。。。,而且还描述的不清楚,我按我的理解给你写了条语句,你看看是不是你想要的

update 表名
set 字段名 = case when 条件1 then '1' when 条件2 then '2' when 条件3 then '3' when 条件4 then '4' end;
EncoreDw 2012-04-15
  • 打赏
  • 举报
回复
z这里面 这几个是死的,修改的是条件。。。


update tables set = '1' where (活儿)

update tables set ='2' where (活得)

update tables set ='3 ' where ....

update tables set ="4" where ...


EncoreDw 2012-04-15
  • 打赏
  • 举报
回复
四点多,给我回帖,,我确实震惊了。太谢谢了。。


我说一下我的吧。。

update tables set ='1(是字符串的)' where 条件。(i)
i := i + 1 ;
update tables set ='2' where 条件(i)
i := i + 1 ;
update tables set ='3' where 条件。。。(i)
i := i + 1 ;
因为循环里面有这样的四条更新语句。 所以 条件无法确定。。。用的是 while
ssqtjffcu 2012-04-15
  • 打赏
  • 举报
回复

--用下面这条语句试试看是不是你想要的
update student s set s.studentnum=mod(s.studentnum+3,4)+1;;

EncoreDw 2012-04-14
  • 打赏
  • 举报
回复
列如: student表 studentnum属性,原先是 1,2,3,4,5,6..............。现在改成 1,2,3,4,;1,2,3,4,;这种。。。student表有一万条这样的数据。。。懂了吧。


ssqtjffcu 2012-04-14
  • 打赏
  • 举报
回复
[Quote=引用楼主 的回复:]
问题是: 一个表里面,有一万条数据。在表里面有一个属性,列如(temp) 属性。
temp的数据为 1, 2, 3, 4, 这样平均循环。
现在要更新成(temp的数据为 1, 2, 3, 4, 这样平均循环。)数据。。

求大侠, 好好想想,,,求求
[/Quote]
平均循环是什么意思,楼主说清楚原来的数据和想要的结果
秋雨飘落 2012-04-14
  • 打赏
  • 举报
回复
写一个循环,逐条更新呢?

3,491

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 高级技术相关讨论专区
社区管理员
  • 高级技术社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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