A DataVeil macro is a text substitution definition.

The definition consists of a macro name and the text substitution value.

A macro name always begins with a '#" character followed by an identifier.

The user can then use the macro name in many parts of a DataVeil project where text would ordinarily appear, such as in Where conditions, User SQL Value masks, Pre-Masking and Post-Masking-Scripts.

The purpose of macros is to centralize commonly used masking text into a single source so that it can be more easily managed within not just a single masking project but across multiple projects too. For example, if a Where condition is the same for many columns, then instead of having to repeat the definition in every mask, a macro name can be used. Therefore, if in future the Where condition needs to be updated then only the macro definition needs to be updated and references shall be automatically updated.

Macros are recursive. This means that a macro can reference other macros.

Macros have scope. They can be defined at the scope level of: column, table, database, project and component. For example, if a macro #rate is used by a User SQL Value mask, then first the column's macro definitions are searched (defined in the column's Macros tab). If found then it is used. If not found then the column's parent table definition is searched. If not found then the parent database definition is searched. If not found then the project definition is searched. If not found then the Macro Components definition is searched. If not found anywhere then an error is returned.

A Macro can define alternate values for different DBMS types.




A user-defined macro name always begins with a '#' followed by an alphanumeric character and optionally followed by more alphanumeric and underscore ('_') characters.

Note that the first character after '#' may not be an underscore character as these are reserved by DataVeil system-defined macros.


System-Defined Macros

A DataVeil system-defined macro name always begins with '#' followed by an underscore character. i.e. '#_'.



Returns the value of the column name where the macro is expanded. The name shall be enclosed within the DBMS's quotation characters used for identifiers such as [ ] for SQL Server or " " for Oracle . For example, on SQL Server a column name returned may be [CUSTOMER_ID], on Oracle it would be "CUSTOMER_ID".


Returns a boolean value according to whether the current column value is a valid JSON record.

For Azure SQL DB and SQL Server this macro shall expand to:  (ISJSON(#_column_name) > 0)

For Oracle this macro shall expand to:  (#_column_name IS JSON)

For any other DBMS this macro shall return a compile error.

Typical use for the macro would be in a Where condition for masks that require a valid JSON record, such within a JSON mask. This means that the same mask definition can be used across Oracle, SQL Server and Azure SQL DB projects such as in a single Mask Component definition or for migrated projects.



Used exclusively from within a mask's Pre/Post SQL option.