Table of Contents

Search

  1. Preface
  2. The Transformation Language
  3. Constants
  4. Operators
  5. Variables
  6. Dates
  7. Functions
  8. Creating Custom Functions
  9. Custom Function API Reference

Transformation Language Reference

Transformation Language Reference

MOD

MOD

Returns the remainder of a division calculation. For example,
MOD(8,5)
returns 3.

Syntax

MOD(
numeric_value
,
divisor
)
The following table describes the arguments for this command:
Argument
Required/
Optional
Description
numeric_value
Required
Numeric datatype. The values you want to divide. You can enter any valid transformation expression.
divisor
Required
The numeric value you want to divide by. The divisor cannot be 0.

Return Value

Numeric value of the datatype you pass to the function. The remainder of the numeric value divided by the divisor.
NULL if a value passed to the function is NULL.

Examples

The following expression returns the modulus of the values in the PRICE port divided by the values in the QTY port:
MOD( PRICE, QTY )
PRICE
QTY
RETURN VALUE
10.00
2
0
12.00
5
2
9.00
2
1
15.00
3
0
NULL
3
NULL
20.00
NULL
NULL
25.00
0
Error. Integration Service does not write row.
The last row (25, 0) produced an error because you cannot divide by 0. To avoid dividing by 0, you can create an expression similar to the following, which returns the modulus of Price divided by Quantity only if the quantity is not 0. If the quantity is 0, the function returns NULL:
MOD( PRICE, IIF( QTY = 0, NULL, QTY ))
PRICE
QTY
RETURN VALUE
10.00
2
0
12.00
5
2
9.00
2
1
15.00
3
0
NULL
3
NULL
20.00
NULL
NULL
25.00
0
NULL
The last row (25, 0) produced a NULL rather than an error because the IIF function replaces NULL with the 0 in the QTY port.

0 COMMENTS

We’d like to hear from you!