4.Oracle if else

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_29956725/article/details/88050527

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;
----------------------------------------------------------------------------------------------------------------------

猜你喜欢

转载自blog.csdn.net/qq_29956725/article/details/88050527