MOD(a, b)Parameters Used: This function accepts two parameters a and b. This function gives remainder as the output when the input number a is divided by b. Return Value: This function returns the remainder when a is divided by b. Supported Versions of Oracle/PLSQL is given below:
- Oracle 12c
- Oracle 11g
- Oracle 10g
- Oracle 9i
- Oracle 8i
DECLARE Test_Number number1 := 15; Test_Number number2 := 4; BEGIN dbms_output.put_line(MOD(Test_Number number1, Test_Number number2)); END;Output:
3In the above example, when the numeric value 15 is divided by 4 then it returns the remainder of 3 as output. Example-2:
DECLARE Test_Number number1 := 15; Test_Number number2 := 0; BEGIN dbms_output.put_line(MOD(Test_Number number1, Test_Number number2)); END;Output:
15In the above example, when the numeric value 15 is divided by 0 then it returns the remainder of 15 as output. Example-3:
DECLARE Test_Number number1 := 11.6; Test_Number number2 := 2.1; BEGIN dbms_output.put_line(MOD(Test_Number number1, Test_Number number2)); END;Output:
1.1In the above example, when the numeric value 11.6 is divided by 2.1 then it returns the remainder of 1.1 as output. Advantage: This function is used to find the remainder when a is divided by b.
Article Tags :