echo5222 2015-06-05 08:19 采纳率: 0%
浏览 1520

oracle 存储过程 游标的问题

create or replace procedure test_procedure(planetimetableid in integer , gid in integer ,addpeo in integer,peoCount in integer
) is
cursor a_cursor is
select id from seats_info where id in(select id from (select t.*,rownum rn from seats_info t where t.istate ='0' and t.planetimetableid =planetimetableid
and t.isdelete = '0' ) where rn<=peoCount) for update;
begin
for a_cur in a_cursor loop
update seats_info set istate = '1',lastudpdate = sysdate,lastudppeoid =addpeo where id = a_cur.id;
insert into passenger_info(gid, seatsid, addpeo)values(gid,a_cur.id ,addpeo );
insert into test(sid,pid, cou)values(a_cur.id,planetimetableid,peoCount);
end loop;
commit;
-- ReturnValue:=1;
end test_procedure;

单独执行查询语句时 select id from seats_info where id in(select id from (select t.*,rownum rn from seats_info t where t.istate ='0' and t.planetimetableid =63
and t.isdelete = '0' ) where rn<=2) 能返回正确的数据
但是在存储过程中游标取出来的a_cui.id 数据不正确

求大神解答~~~帮忙看看哪里写错了

  • 写回答

3条回答

  • edouardzyc 2015-06-05 09:44
    关注

    select id from seats_info where id in(select id from (select t.*,rownum rn from seats_info t where t.istate ='0' and t.planetimetableid =planetimetableid
    and t.isdelete = '0' ) where rn<=peoCount) for update;

    你这句话干嘛要 for update 你这样锁表了
    后面的 update seats_info 语句应该没法运行把

    评论

报告相同问题?

悬赏问题

  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题