1. IF xxxx then.....else ..... endif; 判断
declare nowDate varchar2(100);
begin
select to_char(SYSDATE,'yyyy-mm-dd') into nowDate from dual;
dbms_output.put_line(nowDate);
if nowDate >'2017'
then dbms_output.put_line('日期大于2017年');
else
dbms_output.put_line('日期小于等于2017年');
end if;
end;
2. IF xx then.... elsif xxxx then ...... else.......endif; 判断
--------------------------------------------------------------------------------------------------
declare
nowDate varchar2(100):='2218';
begin
if nowDate ='2017'
then
dbms_output.put_line('年份为:'|| nowDate);
elsif nowDate ='2018'
then
dbms_output.put_line('年份为:'|| nowDate);
elsif nowDate ='2019'
then
dbms_output.put_line('年份为:'|| nowDate);
else
dbms_output.put_line('你们猜错了');
dbms_output.put_line('年份为:'|| nowDate);
end if;
end;
----------------------------------------------------------------------------------------------------------------------