pl/sql中的取模运算

pl/sql语言的取模(即求余)运算不使用大部分语言所支持的 a%b

而是使用函数 mod(a,b)

例子如下:写一个匿名块判断某年是否是闰年,能被4但是不能被100整除,或者能被400整除

 1 declare
 2   judge      varchar2(200);
 3   year_input number;
 4 begin
 5   year_input := '&输入年份';
 6   if (mod(year_input, 400) = 0 or
 7      (mod(year_input, 4) = 0 and mod(year_input, 100) != 0)) then
 8     judge := 'Leap Year';
 9   else
10     judge := 'Not a Leap Year';
11     dbms_output.put_line(judge);
12   end if;
13 end;

2017-07-26

 

posted @ 2017-07-26 20:13  lilian'sblog  阅读(4473)  评论(0编辑  收藏  举报