1. 撒子是IF...THEN...条件语句
格式:
IF THEN
END IF;
declare
x number :=9;
begin
if x<10 then
dbms_output.put_line('x is less than10');
end if;
end;
/
x is less than10
PL/SQL 过程已成功完成。
declare
x number :=9;
begin
if x<10 then
insert into testloop values(1111);
end if;
end;
/
SQL> select * from testloop;
A
----------
1111
2.撒子是IF...THEN...ELSE...条件语句
格式:
IF THEN
ELSE
END IF;
declare
x number :=20;
begin
if x<10 then
insert into testloop values(1111);
else
insert into testloop values(2222);
end if;
end;
/
SQL> select * from testloop;
A
----------
1111
11143431
2222
3.撒子是IF...THEN...,ELSEIF THEN...,ELSEIF...THEN,ELSE...END IF;
格式:
IF THEN
ELSIF THEN
ELSIF THEN
ELSE
END IF;
DECLARE
x NUMBER(3) := 47;
BEGIN
IF x < 10 THEN
dbms_output.put_line('X is less than 10');
ELSIF x = 10 THEN
dbms_output.put_line('X is equal to 10');
ELSIF x < 100 THEN
dbms_output.put_line('X is between 11 and 99');
ELSE
dbms_output.put_line('X is greater than 99');
END IF;
END;
/