1. 程式人生 > >數據庫:循環語句--1:if then/elsif/end if.

數據庫:循環語句--1:if then/elsif/end if.

循環語句 語句 lec sql語句 rom where varchar then 工資

if循環語句:

1:語法:

IF <布爾表達式> THEN

PL/SQL 和 SQL語句
END IF;
--或
IF <布爾表達式> THEN
PL/SQL 和 SQL語句
ELSIF
其它語句
END IF;

2:實例:

--查詢姓名是Scott的工資。
declare
V_ename emp.ename%type :=‘SCOTT‘;
V_sal emp.sal%type;
V_comment varchar2(60);

begin
select sal into V_sal from emp where ename=V_ename;
if V_sal<1500 then
V_comment :=‘Fairly less‘;
elsif V_sal<3000 then
V_comment :=‘A little more‘;
else
V_comment :=‘Lots of money‘;
end if;
dbms_output.put_line(V_sal);
dbms_output.put_line(V_comment);
end;

數據庫:循環語句--1:if then/elsif/end if.