全部版块 我的主页
论坛 数据科学与人工智能 大数据分析 Oracle数据库及大数据解决方案
8028 3
2014-10-07

在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;


二维码

扫码加我 拉你入群

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

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

全部回复
2014-10-7 21:30:17
提示: 作者被禁止或删除 内容自动屏蔽
二维码

扫码加我 拉你入群

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

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

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:}
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群