游标的使用
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
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
相关文章推荐
- 有关pl/sql的游标, 文本拼接和绑定变量使用小心得.
- 游标的使用
- sql中游标的使用
- oracle 游标使用(动态游标)
- 游标使用示例
- 游标的使用
- MySql中游标的定义与使用方式
- Sql游标使用2例
- Oracle 游标使用大全
- SQL SERVER2000/20005中游标的使用操作
- SQL游标使用实例
- Oracle 10g使用游标更新或删除数据
- Oracle 参照游标(SYS_REFCURSOR)使用
- Oracle 游标使用总结(好文章)
- oracle中函数,游标的使用
- SQLServer游标使用
- SQL server 游标,随机数使用
- SQL游标原理和使用方法
- mysql 游标的使用总结
- 游标使用大全