楼主: 龙安洋
7708 3

Oracle存储过程中的elsif的应用 [推广有奖]

  • 3关注
  • 0粉丝

初中生

95%

还不是VIP/贵宾

-

威望
0
论坛币
129 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
193 点
帖子
6
精华
0
在线时间
23 小时
注册时间
2014-10-4
最后登录
2020-1-29

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

在PL/SQL里面使用if语句的时候,记得是elsif而不是elseif:

if...elsif...elsif....end if

学习案例如下:

declare

  region        varchar2(100) := '&region';--声明region的字符变量且默认标签为region

  country_count number := 0;               --声明country_count的数值变量

begin

  if upper(region) = 'EUROPE' then

    select count(*) into country_count from countries where region_id = 1;

    dbms_output.put_line('There are ' || country_count ||

                         ' countries in  the Europe region.');

  elsif upper(region) = 'AMERICAS' then

    select count(*) into country_count from countries where region_id = 2;

    dbms_output.put_line('There are ' || country_count ||

                         ' countries in  the Americas region.');

  elsif upper(region) = 'ASIA' then

    select count(*) into country_count from countries where region_id = 3;

    dbms_output.put_line('There are ' || country_count ||

                         ' countries in  the ASIA region.');   

  elsif upper(region) = 'MIDDLE EAST AND AFRICA' then

    select count(*) into country_count from countries where region_id = 4;

    dbms_output.put_line('There are ' || country_count ||

                         ' countries in  the middle East and Africa region.');   

  else

    dbms_output.put_line('You have entered an invaid region ,please try again');

  end if;

  end;


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Oracle 存储过程 ELS CLE ACL Oracle 工具 转帖

沙发
梅西西是猫 发表于 2014-10-7 21:30:17 |只看作者 |坛友微信交流群
提示: 作者被禁止或删除 内容自动屏蔽

使用道具

藤椅
fjrong 在职认证  发表于 2014-10-7 22:41:16 来自手机 |只看作者 |坛友微信交流群
龙安洋 发表于 2014-10-7 20:58
在PL/SQL里面使用if语句的时候,记得是elsif而不是elseif:if...elsif...elsif....end if[/bac ...
thanks for sharing

使用道具

板凳
龙安洋 在职认证  发表于 2014-10-7 22:43:04 |只看作者 |坛友微信交流群
you're  are  welcome!{:3_41:}

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-25 22:42