山一程_水一程 2017-11-22 05:40 采纳率: 0%
浏览 895

存储过程用游标的方式写出来怎么写

create or replace procedure p_lx is
begin
UPDATE AB01_QHD1 t set t.w =1 where t.name in (select t.name from AB01_QHD1 t,AA01_QHD2 t2 where t.name=t2.name);
commit;

end p_lx;

用游标写怎么写 实现上面的代码

  • 写回答

1条回答 默认 最新

  • 半世笙箫 2017-11-22 08:33
    关注

    create procedure p_lx
    as
    begin
    declare @bianliang varchar(50) ;
    set @bianliang='';
    declare cur cursor fast_forward for
    select t.name from AB01_QHD1 t join AA01_QHD2 t2 on t.name=t2.name
    open cur
    fetch next from cur into @bianliang
    while @@fetch_status=0
    begin
    UPDATE AB01_QHD1 set w =1 where name=@bianliang
    fetch next from cur into @bianliang
    end
    close c ur
    deallocate cur
    end
    go

    这是SQL SERVER的实现方式。你这个不需要写存储过程或者游标的。

    评论

报告相同问题?

悬赏问题

  • ¥15 MATLAB动图的问题
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名