8-Byte and 16-Byte Decimal UDFs

These UDFs work on the Decimal data types that are either 8 or 16 bytes in size. The 8-byte Decimal data types have a precision between 10 and 18 digits, while the 16-byte Decimals have a precision between 19 and 38 digits.

Note: Only one set of Decimal UDFs can be created for each range. The user must provide the UDF name. It is recommended that you replace with, for example, 10_2 if the target data type is Decimal(10,2) to get a function pty_decimal_10_2enc, or 22_3 if the target data type is Decimal(22,3) to get pty_decimal_22_3enc.

pty_decimalenc

This UDF protects the decimal value with a data element for encryption.

Signature:

pty_decimal<n>enc(col DECIMAL<n>, dataelement VARCHAR, resultlen INTEGER, communicationid INTEGER, scid INTEGER)

Parameters:

NameTypeDescription
colDECIMAL(m,n)Specifies the data to protect.
dataelementVARCHARSpecifies the name of the data element.
resultlenINTEGERSpecifies the length of the buffer to hold the result.
communicationidINTEGERSpecify the value as 0. This parameter is deprecated.
scidINTEGERSpecify the value as 0. This parameter is deprecated.

Returns:
The function returns the protected VARBYTE value.

Exception:
If the user does not have protect access rights in the policy, then the UDF terminates with an error message explaining what went wrong.

Example:

select pty_decimal37_1enc(26656.0, 'AES256', 100, 0,0);

pty_decimaldec

This UDF unprotects the protected decimal value.

Signature:

pty_decimal<n>dec(col VARBYTE, dataelement VARCHAR, communicationid INTEGER, scid INTEGER)

Parameters:

NameTypeDescription
colVARBYTESpecifies the data to unprotect.
dataelementVARCHARSpecifies the name of the data element.
communicationidINTEGERSpecify the value as 0. This parameter is deprecated.
scidINTEGERSpecify the value as 0. This parameter is deprecated.

Returns:

  • The function returns the unprotected DECIMAL value.
  • The function returns NULL when the user has no access to the data in the policy.

Exception:
If you configure an exception in the policy and the user does not have access, then the UDF terminates with an error message explaining what went wrong.

Example:

select pty_decimal37_1dec(pty_decimal37_1enc(26656.0, 'AES256', 100, 0,0), 'AES256', 0,0);

pty_decimaldecex

This UDF unprotects the protected decimal value and returns an error instead of NULL if the user does not have access.

Signature:

pty_decimal<n>decex(col VARBYTE, dataelement VARCHAR, communicationid INTEGER, scid INTEGER)

Parameters:

NameTypeDescription
colVARBYTESpecifies the data to unprotect.
dataelementVARCHARSpecifies the name of the data element.
communicationidINTEGERSpecify the value as 0. This parameter is deprecated.
scidINTEGERSpecify the value as 0. This parameter is deprecated.

Returns:
The function returns the unprotected DECIMAL value.

Exception:
If you configure an exception in the policy and the user does not have access, then the UDF terminates with an error message explaining what went wrong.

Example:

select pty_decimal37_1decex(pty_decimal37_1enc(26656.0, 'AES256', 100, 0,0), 'AES256', 0,0);

Last modified : February 20, 2026