CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
(图)邪恶的韩国UMPC 使用 Java 编写数据库应用新规范
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Oracle >  开发

很简单的 if 的SQL更新问题

楼主yycxx(yycxx01)2005-06-03 14:49:22 在 Oracle / 开发 提问

declare  
  cursor   ns   is   select   name,salary   from   employee;  
  nam   employee.name%type;  
  sal   employee.salary%type;  
  begin  
    open   ns;  
    fetch   ns   into   nam,sal;  
    while   ns%found   loop  
          if   sal<2000   then  
        update   employee   set   salary   =   salary   *   1.2   where   salary   <   2000;  
  else  
        if   sal<5000   then    
        update   employee   set   salary   =   salary   *   1.1   where   salary<5000   and   salary>2000;  
        else  
              update   employee   set   salary   =   salary   *   1.05   where   salary>5000;  
        end   if;  
        dbms_output.put_line('after   update   salary:   '||to_char(sal));  
        fetch   ns   into   nam,sal;  
    end   loop;  
    close   ns;  
    commit;  
  end;  
   
  报错为 需要 if   的时候出现了 loop  
  但是我改成下面的样子就可以运行,这是怎么回事,为什么上面会报错?  
  declare  
  cursor   ns   is   select   name,salary   from   employee;  
  nam   employee.name%type;  
  sal   employee.salary%type;  
  begin  
    open   ns;  
    fetch   ns   into   nam,sal;  
    while   ns%found   loop  
          if   sal<2000   then  
        update   employee   set   salary   =   salary   *   1.2   where   salary   <   2000;  
        end   if;  
        dbms_output.put_line('after   update   salary:   '||to_char(sal));  
        fetch   ns   into   nam,sal;  
    end   loop;  
    close   ns;  
    commit;  
  end;  
   
  问题点数:30、回复次数:2Top

1 楼bzszp(SongZip)回复于 2005-06-03 14:57:18 得分 30

if   ...   then  
  ...  
  elsif   ...   then  
  ...  
  end   if;Top

2 楼bluecocoqd(小骗骗)回复于 2005-06-03 15:27:14 得分 0

哈哈,你就是笨蛋醒了又睡吧?Top

相关问题

  • 很简单的sql更新语句,本人新手,请指教
  • 晕了,关于更新数据的问题!很简单的。
  • 更新问题SQL
  • SQL更新问题
  • 简单的更新语句!
  • 请教一下很简单的动态更新表格行的问题
  • 很简单的ASP。NET提交更新的问题,我郁闷,我急
  • 【简单问题!如何在存储过程加点更新其它表的SQL语句呀?】
  • 一个简单的SQL更新语句,但提示 update 出错, 请问是怎么回事儿呀?
  • 求一条简单的SQL更新语句,高手请进,急,解决马上给分,谢谢!!

关键词

  • nam
  • sal
  • salary
  • ns
  • declarecursor
  • 报错
  • employee
  • while ns%found
  • fetch
  • loop

得分解答快速导航

  • 帖主:yycxx
  • bzszp

相关链接

  • Oracle类图书

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo