一、只有一個if
if ....then
end if;
二、兩種選擇
if .....then
else
...
end if;
三、多種選擇
if .... then
elsif....then
else....end if;
注意多重判斷中是elsif不是elseif
舉例如下:
CREATE OR REPLACE PROCEDURE Test (a in varchar2,b out varchar2)
is
c;
begin
select nvl(count(*),-1) c from table where Name=a ;
if c <= 0 then
----輸出沒有此名字
---- DBMS_OUTPUT.PUT_LINE('對不起沒有此人');
message:=('對不起'||nvl(objname,'輸入姓名')||'不存在!');
elsif temp_seed >0 then
message:=('Hello ' || objname || '!');
else
message:=('程序有異常!');
end if;
end Test;
