Integer UDFs

pty_integerenc

This UDF protects integer value using an Encryption data element.

Signature:

pty_integerenc(col INTEGER, dataelement VARCHAR, resultlen INTEGER, communicationid INTEGER, scid INTEGER)

Parameters:

NameTypeDescription
colINTEGERSpecifies 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_integerenc(1234, 'AES256', 100, 0,0);

pty_integerdec

This UDF unprotects the protected integer value.

Signature:

pty_integerdec(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 INTEGER 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_integerdec(pty_integerenc(1234, 'AES256', 100, 0,0), 'AES256', 0,0);

pty_integerdecex

This UDF unprotects the protected integer value.

Signature:

pty_integerdecex(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 INTEGER value.

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

Example:

select pty_integerdecex(pty_integerenc(1234, 'AES256', 100, 0,0), 'AES256', 0,0);

pty_integerins

This UDF protects the integer value using type-preserving data elements, such as, tokens and No Encryption for access control.

Signature:

pty_integerins(col INTEGER, dataelement VARCHAR, resultlen INTEGER, communicationid INTEGER, scid INTEGER)

Parameters:

NameTypeDescription
colINTEGERSpecifies 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 INTEGER 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_integerins(1234, 'TE_INT_4', 100, 0,0);

pty_integersel

This UDF unprotects the protected integer value.

Signature:

pty_integersel(col INTEGER, dataelement VARCHAR, communicationid INTEGER, scid INTEGER)

Parameters:

NameTypeDescription
colINTEGERSpecifies the data to protect.
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 INTEGER value.
  • The function returns the protected value if this option is configured in the policy and the user does not have access to the data.
  • The function returns NULL when the user has no access to the data in the policy.

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_integersel(pty_integerins(1234, 'TE_INT_4', 100, 0,0), 'TE_INT_4', 0,0);

pty_integerselex

This UDF unprotects the protected integer value.

Signature:

pty_integerselex(col INTEGER, dataelement VARCHAR, communicationid INTEGER, scid INTEGER)

Parameters:

NameTypeDescription
colINTEGERSpecifies 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 INTEGER value.
  • The function returns the protected value if this option is configured in the policy and the user does not have access to the data.

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

Example:

select pty_integerselex(pty_integerins(1234, 'TE_INT_4', 100, 0,0), 'TE_INT_4', 0,0);

pty_integerhash

This UDF calculates the hash value for integer value.

Attention: This is a one-way function and you cannot unprotect the data.

Signature:

pty_integerhash(col INTEGER, dataelement VARCHAR, resultlen INTEGER, communicationid INTEGER, scid INTEGER)

Parameters:

NameTypeDescription
colINTEGERSpecifies 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 hash value.
  • The function returns NULL when the user has no access to the data in the policy.

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_integerhash(1234, 'HMAC_SHA256', 100, 0,0);

Caution: Starting from the version 10.0.x, the HMAC-SHA1 protection method is deprecated.
It is recommended to use the HMAC-SHA256 protection method instead of the HMAC-SHA1 protection method.
For assistance in switching to a different protection method, contact Protegrity Support.


Last modified : February 20, 2026