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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM