2008-04-07
sql 中 sql%rowcount 判断执行SQL受影响的行数
sql 中 sql%rowcount 判断执行SQL受影响的行数
例子:
update work_order
set order_state = '1'
where line_id = p_line_id
and order_state = '0'
and order_type = 'DPY'
and ORDER_PRIORITY = (select min(ORDER_PRIORITY)
from work_order
where order_state = '0'
and order_type = 'DPY'
and LINE_ID = p_line_id
and order_priority > 0
group by LINE_ID)
and exists
(select 1
from product_level pl
where pl.pid = pid
and pl.child_pid =
(select (select pid
from product_maintain pm
where pm.product_number =
rw.material_number
and pm.rstate = rw.material_rstate)
from routing_wip rw
where rw.sn = p_sn))
and rownum <= 1;
if sql%rowcount > 1 then //代表上面update语句影响的行数
raise_application_error (-20015,
'Work order with same priority in the waiting queue ! ');
end if ;
例子:
update work_order
set order_state = '1'
where line_id = p_line_id
and order_state = '0'
and order_type = 'DPY'
and ORDER_PRIORITY = (select min(ORDER_PRIORITY)
from work_order
where order_state = '0'
and order_type = 'DPY'
and LINE_ID = p_line_id
and order_priority > 0
group by LINE_ID)
and exists
(select 1
from product_level pl
where pl.pid = pid
and pl.child_pid =
(select (select pid
from product_maintain pm
where pm.product_number =
rw.material_number
and pm.rstate = rw.material_rstate)
from routing_wip rw
where rw.sn = p_sn))
and rownum <= 1;
if sql%rowcount > 1 then //代表上面update语句影响的行数
raise_application_error (-20015,
'Work order with same priority in the waiting queue ! ');
end if ;
发表评论
提醒: 该博客已发表在公共论坛,博客所有留言会成为论坛回贴,留言请注意遵守论坛发贴规则
- 浏览: 4243 次

- 详细资料
搜索本博客
最近加入圈子
最新评论
-
NET判断输入是否为double ...
受教了!谢谢楼主
-- by liuzhenyu170 -
一个截取字符串的方法
呵呵谢谢各位,我是想让他成为一个通用的东西,以后在编写存储过程时,可以直接用,就 ...
-- by 心似海 -
动态SQL
既然是存储过程,当temp_str的值有很多的时候, 可以考虑把temp_str ...
-- by armorking -
一个截取字符串的方法
用函数跑得会比较慢。。。不如再来个表像二楼说的1:N 想了想,写成下面这样貌视 ...
-- by qiuyuanshan -
一个截取字符串的方法
明明A、B两个字段是1:N关系, 用两张主从关系的表来描述,非常轻松 却偏偏要把 ...
-- by armorking






评论排行榜