The CREATE_WRAPPED procedure transforms a plain text DDL object definition into an obfuscated DDL object definition and then deploys the object in the database.
In an obfuscated DDL statement, the procedural logic and embedded SQL statements are encoded in such a way that any intellectual property in the logic cannot be easily extracted.
>>-DBMS_DDL.CREATE_WRAPPED--(--object-definition-string--)-----><
EXECUTE privilege on the DBMS_DDL module.
1. Create an obfuscated function computing a yearly salary from an hourly wage given a 40 hour workweek
CALL DBMS_DDL.CREATE_WRAPPED('CREATE FUNCTION ' ||
'salary(wage DECFLOAT) ' ||
'RETURNS DECFLOAT ' ||
'RETURN wage * 40 * 52');
SELECT text FROM SYSCAT.ROUTINES
WHERE routinename = 'SALARY'
AND routineschema = CURRENT SCHEMA;
Upon successful execution of the CALL statement, The SYSCAT.ROUTINES.TEXT column for the row corresponding to routine 'SALARY' would be something of the form:
CREATE FUNCTION salary(wage DECFLOAT) WRAPPED SQL09072 obfuscated-text
2. Create an obfuscated trigger setting a complex default
CALL DBMS_DDL.CREATE_WRAPPED('CREATE OR REPLACE TRIGGER ' ||
'trg1 BEFORE INSERT ON emp ' ||
'REFERENCING NEW AS n ' ||
'FOR EACH ROW ' ||
'WHEN (n.bonus IS NULL) ' ||
'SET n.bonus = n.salary * .04');
SELECT text FROM SYSCAT.TRIGGERS
WHERE trigname = 'TRG1'
AND trigschema = CURRENT SCHEMA;
Upon successful execution of the CALL statement, The SYSCAT.TRIGGERS.TEXT column for the row corresponding to trigger 'TRG1' would be something of the form:
CREATE OR REPLACE TRIGGER trg1 WRAPPED SQL09072 obfuscated-text