The Oracle MOD function performs a “modulo division” on the numbers you specify. A modulo division is where a division is performed using two numbers, and the remainder is returned by the function.
For example, the division of 8/5 is 1.6. Using modulo division, 8/5 will work out there is one 5 contained in the 8, with 3 left over. The MOD function would return 3 in this example.
The syntax of the MOD function is:
The numerator is the number mentioned first in the division, or the one that is on top of the division sign. In a division such as 15/4, this would be the 15.
The denominator is the number mentioned second in the devision, or hte one that is on the bottom of the division sign. In a division such as 15/4, this would be the 4.
The parameters can be any numeric data type, and the return type depends on these parameters. This means MOD can return a whole number or a decimal number.
The calculation for the Oracle MOD function is: numerator - denominator * FLOOR(numerator / denominator).
If the denominator is 0, the function returns the value of the numerator. This is done to prevent “divide by 0” errors.
For more information about the MOD function, including how to return every second row, how it’s different to REMAINDER, and to see the SQL code used in these examples, read the related article here:
A trigger is a named PL/SQL unit that is stored in the database and executed ( fired ) in response to a specified event that occurs in the database.
Overview of Triggers.
A trigger is a named program unit that is stored in the database and fired (executed) in response to a specified event. The specified event is associated with either a table, a view, a schema, or the database, and it is one of the following:
A database manipulation (DML) statement ( DELETE , INSERT , or UPDATE )
A database definition (DDL) statement ( CREATE , ALTER , or DROP )
A database operation ( SERVERERROR , LOGON , LOGOFF , STARTUP , or SHUTDOWN )
The trigger is said to be defined on the table, view, schema, or database.
A DML trigger is fired by a DML statement, a DDL trigger is fired by a DDL statement, a DELETE trigger is fired by a DELETE statement, and so on.
An INSTEAD OF trigger is a DML trigger that is defined on a view (not a table). The database fires the INSTEAD OF trigger instead of executing the triggering DML statement. For more information, see Modifying Complex Views (INSTEAD OF Triggers).
A system trigger is defined on a schema or the database. A trigger defined on a schema fires for each event associated with the owner of the schema (the current user). A trigger defined on a database fires for each event associated with all users.
A simple trigger can fire at exactly one of the following timing points :
Before the triggering statement executes.
After the triggering statement executes.
Before each row that the triggering statement affects.
After each row that the triggering statement affects.
A compound trigger can fire at more than one timing point. Compound triggers make it easier to program an approach where you want the actions you implement for the various timing points to share common data. For more information, see Compound Triggers.