PLSQL: IF-THEN-ELSE
来源:互联网 发布:罗马城市 知乎 编辑:程序博客网 时间:2024/05/01 07:06
There are three different syntaxes for these types of statements.
Syntax #1: IF-THEN
IF condition THEN
{...statements...}
END IF;
Syntax #2: IF-THEN-ELSE
IF condition THEN
{...statements...}
ELSE
{...statements...}
END IF;
Syntax #3: IF-THEN-ELSIF
IF condition THEN
{...statements...}
ELSIF condition THEN
{...statements...}
ELSE
{...statements...}
END IF;
Here is an example of a function that uses the IF-THEN-ELSE statement:
CREATE OR REPLACE Function IncomeLevel
( name_in IN varchar2 )
RETURN varchar2
IS
monthly_value number(6);
ILevel varchar2(20);
cursor c1 is
select monthly_income
from employees
where name = name_in;
BEGIN
open c1;
fetch c1 into monthly_value;
close c1;
IF monthly_value <= 4000 THEN
ILevel := 'Low Income';
ELSIF monthly_value > 4000 and monthly_value <= 7000 THEN
ILevel := 'Avg Income';
ELSIF monthly_value > 7000 and monthly_value <= 15000 THEN
ILevel := 'Moderate Income';
ELSE
ILevel := 'High Income';
END IF;
RETURN ILevel;
END;
In this example, we've created a function called IncomeLevel. It has one parameter called name_in and it returns a varchar2. The function will return the income level based on the employee's name.
- PLSQL: IF-THEN-ELSE
- PLSQL:if then else语句段
- bash if... then....else
- If...Then...Else
- if-then和if-then-else语句
- plsql if then 使用
- 条件编译 #If...Then...#Else
- IDCAMS IF-THEN-ELSE statement
- 3.8 If-then-else表达式
- plsql控制结构if then
- Callback function与if-then-else
- Traits: 类型的else-if-then机制
- shell 脚本 if then else fi
- Traits技术:类型的if-else-then
- sql中IF ELSE THEN语法
- if then else 的特殊简写方法
- decode 函数之if-then-else逻辑
- 4 Bash If Statement Examples ( If then fi, If then else fi, If elif else fi, Nested if )
- JavaScript onclick传递对象参数(easyui传递一行数据时)错误:uncaught SyntaxError: Unexpected identifier
- Tomcat 5.5部署jsp项目—jsp乱码问题的解决
- Spark-ML-01-小试spark分析离线商品信息
- fusioncharts Y轴不显示中文的解决方法
- how to use Google
- PLSQL: IF-THEN-ELSE
- SQL step by step
- Maven----导入项目后报错
- linux_用户及用户组管理
- 现货黄金和TD黄金的比例
- 防表单重复提交
- Linux设备模型(5)_device和device driver
- 蓝桥杯算法提高——最大乘积
- 记事中快速加当前日期时间