User-defined functions (UDF) are called in a query just like other system-defined functions and are tied to the table context. If a user-defined function uses a DDM-configured field, you cannot view the data unless you are authorized to unmask that field.

Example

The following example illustrates a SELECT statement that uses a DDM-configured field as an input parameter to invoke a UDF.
/******** UDF setup **************/
Create FUNCTION IncDiscount(discount integer, incpercent integer)
RETURN integer
BEGIN
RETURN discount + incpercent;
END;

/* Run a SELECT statement using IncDiscount()*/
SELECT IncDiscount(Discount, 5) FROM PUB.Customer WHERE discount = 10;
In this example, the UDF code increases the discount by the given percentage. Run a SELECT statement to call the IncDiscount function by passing the Discount field of the PUB.Customer table as an input parameter along with the percentage value. Here, Discount is a DDM-configured field. If you have the necessary unmasking privileges, the UDF uses the unmasked values of Discount to calculate the discount increment. In the absence of these privileges, it uses the masked value of Discount .