Oracle流程控制语句
发布日期:2021-05-07 00:45:34 浏览次数:46 分类:原创文章

本文共 565 字,大约阅读时间需要 1 分钟。

1.判断

if  判断条件  then 
          满足条件语句执行
end if ; -- 这里是结束符号

【例Ⅰ】

set serveroutput on;

declare  
      counter number;

begin
      select into count(empno) into counter emp;  --这里使用select into 赋值给 counter 
     if counter >10 then   --判断条件
     dbms_output.put_line(' emp表记录数量大于10条 ');     -- 满足条件语句执行
     end if ;

end;
/

2.
if  判断条件  then 
          不满足条件语句执行
end if ; -- 这里是结束符号

 

3.

if  判断条件1  then 
          满足条件语句 1 执行
elsif 判断条件 2 then 
         满足条件语句 1 执行

end if;

【2】
declare 

v_empno emp.empno%type;
v_sal emp.sal%type;

begin
        --从键盘获取编号 7369,7788
         v_empno :=& empno;
     select sal  into  v_sal    from emp where empno=v_empno;
      if  v_sal >3000 then 
                dbms_ou

上一篇:Oracle中case语句的使用
下一篇:【六袆】Oracle变量和常量

发表评论

最新留言

关注你微信了!
[***.104.42.241]2025年04月14日 22时45分07秒