您的位置:首页 > 其它

游标的使用

2012-06-06 09:29 169 查看
--建立处理游标

declare sub_order_cur cursor for

      select tbSub_Order.stock_no ,unit_price ,order_quantity ,unit ,order_remark ,stockreceive_remark ,order_amount

        from tbSub_Order

        inner join tbMaster on tbMaster.stock_no=tbSub_Order.stock_no

        where location_id=@location_id and order_no =@order_no and status not in (3,5,6)

open sub_order_cur

fetch next from sub_order_cur into @stock_no,@unit_price ,@order_quantity,@unit,@order_remark,@stockreceive_remark ,@order_amount

while @@fetch_status=0

begin

    insert into OPENDATASOURCE('SQLOLEDB','Data Source=10.200.253.25;User Id=SMSLinkuser;Password=SMS@link*2012%^&')    .AIS20120531133013.dbo.t_ZDF_SynPOOrderEntry

values (@FUUID ,@stock_no ,@unit_price,@order_quantity ,@unit ,@order_remark ,@stockreceive_remark,@order_amount )

fetch next from sub_order_cur into @stock_no,@unit_price ,@order_quantity,@unit,@order_remark,@stockreceive_remark ,@order_amount

end

close sub_order_cur

deallocate sub_order_cur
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: