WRAP

The WRAP function transforms a readable DDL statement into an obfuscated DDL statement.

Read syntax diagramSkip visual syntax diagramWRAP( object-definition-string )

In an obfuscated DDL statement, the procedural logic and embedded SQL statements are scrambled in such a way that any intellectual property in the logic cannot be easily extracted.

The schema is SYSIBMADM.

object-definition-string
A string of type CLOB or DBCLOB containing a DDL statement. It can be one of the following SQL statements:
  • CREATE FUNCTION (SQL scalar)
  • CREATE FUNCTION (SQL table)
  • CREATE PROCEDURE (SQL)
  • CREATE TRIGGER
The result is a string of type CLOB(2M) which contains an encoded version of the input statement. The result cannot be null. The encoding consists of a prefix of the original statement up to and including the routine signature or trigger name, followed by the keyword WRAPPED. This keyword is followed by information about the application server that invoked the function. The information has the form pppvvrrm where:
  • ppp identifies the product using the following 3 characters:
    • Start of changeDSN for Db2® for z/OS®End of change
    • QSQ for Db2 for i
    • SQL for Db2 for LUW
  • vv is a two-digit version identifier, such as '07'
  • rr is a two-digit release identifier, such as '02'
  • m is a one-character modification level identifier, such as '0'
For example Db2 for i version 7.3 is identified as 'QSQ07030'.

This application server information is followed by a string of letters (a-z and A-Z), digits (0-9), underscores, and colons.

The encoded DDL statement may be up to one-third longer than the plain text form of the statement. If the result exceeds the maximum length for SQL statements, an error is issued.

Note

The encoding of the statement is meant to obfuscate the content and should not be considered as a form of strong encryption.

Examples

Example 1: Produce an obfuscated version of a function that computes a yearly salary from an hourly wage given a 40 hour work week.

VALUES WRAP('CREATE FUNCTION salary(wage DECFLOAT) RETURNS DECFLOAT 
                       RETURN wage * 40 * 52')    

The result of this statement would be something of the form:

CREATE FUNCTION salary(wage DECFLOAT) WRAPPED QSQ07020 <encoded-suffix>

Example 2: Produce an obfuscated version of a trigger that sets a complex default.

VALUES WRAP('CREATE OR REPLACE TRIGGER trig1 BEFORE INSERT ON emp 
                       REFERENCING NEW AS n FOR EACH ROW 
                       WHEN (n.bonus IS NULL) SET n.bonus = n.salary * .04')    

The result of this statement would be something of the form:

CREATE TRIGGER trig1 WRAPPED QSQ07020 <encoded-suffix>