请教:oracle 多表更新问题

[复制链接]
查看11 | 回复4 | 2015-3-6 11:58:18 | 显示全部楼层 |阅读模式
sql:
update (select n.status n_status from cccccc c, nnnnnnnn n
where c.status = 1 and n.status = 1 and c.batch_no = n.batch_no
and c.prepare_time< sysdateorder by c.prority desc)
set n_status = 233333 where rownum<= 100;
这条sql语句在oracle9i中可以正常执行,但到了oracle10G中就不能执行提示对视图ora-01732:此视图的数据操纵操纵非法(9i和10G只是在应用中发现,是否其他版本有问题还没测试),
但在10g中去掉orader by和rownum都就没问题但这两个都是我所需要的。
请教在10g中怎么写sql可正常执行。并orader by和rownum!
回复

使用道具 举报

千问 | 2015-3-6 11:58:18 | 显示全部楼层
update (select n.status n_status,rownum rn from cccccc c, nnnnnnnn n
where c.status = 1 and n.status = 1 and c.batch_no = n.batch_no
and c.prepare_time< sysdateorder by c.prority desc)
set n_status = 233333 where rn<= 100;
試哈這樣看可以不啊?
回复

使用道具 举报

千问 | 2015-3-6 11:58:18 | 显示全部楼层
原帖由 jack198409 于 2008-4-5 10:38 发表
update (select n.status n_status,rownum rn from cccccc c, nnnnnnnn n
where c.status = 1 and n.status = 1 and c.batch_no = n.batch_no
and c.prepare_time< sysdateorder by c.prority desc)
set n_status = 233333 where rn

还是不行,这个在9i上也不行,报的错误是对视图操作非法!
回复

使用道具 举报

千问 | 2015-3-6 11:58:18 | 显示全部楼层
updatennnnnnnn n
setn.n_status = 233333
where exists (select n.status n_status,rownumfrom cccccc c

where c.status = 1 and n.status = 1 and c.batch_no = n.batch_no

and c.prepare_time< sysdate and rownum<=100 order by c.prority desc)
回复

使用道具 举报

千问 | 2015-3-6 11:58:18 | 显示全部楼层
原帖由 jack198409 于 2008-4-5 10:59 发表
updatennnnnnnn n
setn.n_status = 233333
where exists (select n.status n_status,rownumfrom cccccc c

where c.status = 1 and n.status = 1 and c.batch_no = n.batch_no

and c.prepare_time< sysdate and rownum

多谢这位兄长一直帮忙解决问题,
这个语句我在之强已经试过了,到了orader by后就提示少右边括号。去掉就没问题。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行