Description
The first part of the script simply checks if the user-defined function already
exists in the current database or not. If it already exists, it is
dropped so that the creation of the function will not fail.
The main body of the function determines if it is a leap year or not.
Basically, to determine if it is a leap year, either of the following
conditions must be met:
-
The year must be divisible by 4 and must NOT be divisible by 100.
-
The year must be divisible by 400.
Given this, year 1990, although divisible by 4, is not a leap year because it is
not divisible by 100. On the other hand, year 2000 is a leap year because
it is divisible by 400.