zoukankan      html  css  js  c++  java
  • oracle pl/sql之sql中的---if语句

    pl/sql中为了控制程序的执行方向,引进了if语句,if语句有多种形式

        if....end if 语句 语法如下

            if 条件表达式 then

              pl/sql语句

           end if;

    程序演示如下:

    SQL> set serveroutput on;
    SQL> declare
     a number;
     b number;
     begin
     a:=1;
     b:=2;
     if a>b then
     dbms_output.put_line('a'||'>'||'b');
     else
     dbms_output.put_line('a'||'<'||'b');
     end if;
     end;


    a<b
    PL/SQL procedure successfully completed

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

    if 条件表达式 then

    pl/sql语句 

    elslf 条件表达式2 then

     pl/sql语句2

    elslf 条件表达式3 then

     pl/sql语句3

    else 

    pl/sql语句4

     end if;

    演示程序:

    declare
    year number:=2016;
    flag boolean;
    begin
    if mod(year,4)<>0 then
    flag:=false;
    elsif mod(year,100)<>0 then
    flag:=true;
    elsif mod(year,400)<>0 then
    flag:=false;
    else
    flag:=true;
    end if;

    if flag then
    dbms_output.put_line('闰年');
    else
    dbms_output.put_line('平年');
    end if;
    end;

    结果:

      闰年

    PL/SQL procedure successfully completed

    累了,想想,生活中充满诗和远方,亦不乏仓央嘉措的妙音天女。
  • 相关阅读:
    Codeforces 858B
    区域赛前立FLAG
    GCJ Practice Contest
    UVa 10004 Bicoloring
    UVa 784 Maze Exploration
    Pacemaker+ISCSI实现Apache高可用-环境准备
    多机免密互信
    HAPROXY + Keepalived
    LVS+KEEPALIVED
    oracle-数据库被注入恶意攻击程序的案例恢复
  • 原文地址:https://www.cnblogs.com/ztyy04126/p/4896079.html
Copyright © 2011-2022 走看看