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