网站公告列表

  没有公告

加入收藏
设为首页
联系站长
您现在的位置: 网络学院 >> 程序设计 >> PowerBuilder >> 文章正文
  游标代码举例            【字体:
游标代码举例
作者:佚名    文章来源:不详    点击数:    更新时间:2007-8-16    

1.对低于当前平均价格的书,均提价50%

2对于高于或等于当前平均价格的书,均降价25%

代码如下:

declare title_update cursor

     for select title_id,price from titles

     for update

go

局部变量

declare @avg_price money,@title_id tid,@price money

open title_update

begin tran

计算平均书价

select @avg_price=avg(price) from titles holdlock

fetch title_update into @title_id,@price

while @@sqlstatus!=2

begin

if  @@sqlstatus=1

begin

rollback tran

raiserror 21001 "Fetch failed in cursor"

close title_update

deallocate cursor title_update

return

end

if @price<@avg_price

提价50%

update titles set price = price * $1.50

where current of title_update

else

降价25%

update titles set price = price * $.75

where current of title_update

if @@error!=0

begin

rollback tran

raiserror 22001 "Update failed"

close title_update

deallocate cursor title_update

return

end

fetch title_update into @title_id,@price

end

commit

close title_update

deallocate cursor title_update

go

 

 

 

 

 

 

站内文章搜索 高级搜索
文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
     在PB程序中实现ODBC数据…
     用PB5 设计 串口通讯程序
     如何用VC创建可在PB中调…
     PB连接Microsoft  SQL S…
     用PB编写多线程应用程序
  • 数独算法源代码(未用递归)

  • 静态代码检查工具PC-Lint(一…

  • 数字图像空间滤波常用的函数…

  • 几行代码,轻松让你的界面与…

  • WindowsXP 操作IO端口的Delp…

  • 在delphi7下实现省市县的三级…

  • del调用返回游标的存储过程

  • JAVA中的字符与代码点

  • JSP测试代码连接ACCESS数据库

  • JSP修改删除添加代码ACCESS数…

  •   网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    网络学院©2007 www.23book.net
    为您提供web编程,vb编程,vc编程,服务器架设管理,数据库设计等方面的知识 站长:David