CREATE_WRAPPED

2026-02-11 07:43:39  Updated

The CREATE_WRAPPED procedure encrypts the string of a PL/SQL object definition into a CREATE WRAPPED statement string and executes the statement to create a WRAPPED object.

Syntax

DBMS_DDL.CREATE_WRAPPED (DDL VARCHAR2);
DBMS_DDL.CREATE_WRAPPED(DDL DBMS_SQL.VARCHAR2A,
                        LB  PLS_INTEGER,
                        UB  PLS_INTEGER);
DBMS_DDL.CREATE_WRAPPED(DDL DBMS_SQL.VARCHAR2S,
                        LB  PLS_INTEGER,
                        UB  PLS_INTEGER);

Parameters

Parameter Description
CREATE_WRAPPED (DDL VARCHAR2)
  • DDL: A VARCHAR2 string containing the PL/SQL source code to be obfuscated.
  • RETURN: The return value, a VARCHAR2 string containing the obfuscated PL/SQL code.
  • CREATE_WRAPPED(DDL DBMS_SQL.VARCHAR2A, LB PLS_INTEGER, UB PLS_INTEGER)
  • DDL: A DBMS_SQL.VARCHAR2A array containing the PL/SQL source code to be obfuscated.
  • LB: The lower bound index, a PLS_INTEGER value.
  • UB: The upper bound index, a PLS_INTEGER value.
  • CREATE_WRAPPED(DDL DBMS_SQL.VARCHAR2S,LB PLS_INTEGER,UB PLS_INTEGER)
  • DDL: A DBMS_SQL.VARCHAR2S array containing the PL/SQL source code to be obfuscated.
  • LB: The lower bound index, a PLS_INTEGER value.
  • UB: The upper bound index, a PLS_INTEGER value.
  • Examples

    Use the CREATE_WRAPPED procedure in the DBMS_DDL package to create a wrapped PL/SQL package. It converts the original PL/SQL code into an unreadable form to prevent direct viewing and modification.

    CALL dbms_ddl.create_wrapped(
      '-- this is a comment'                                                   || chr(10) ||
      'create or replace package arithmetic as'                                || chr(10) ||
      '  function add(a number, b number) return number; -- this is a comment' || chr(10) ||
      '  function sub(a number, b number) return number; /* comment */'        || chr(10) ||
      '  function /* comment */ mul(a number, b number) return number;'        || chr(10) ||
      '  /* comment1'                                                          || chr(10) ||
      '     comment2'                                                          || chr(10) ||
      '     comment3 */'                                                       || chr(10) ||
      '  function div(a number, b number) return number;'                      || chr(10) ||
      'end arithmetic;'                                                        || chr(10) ||
      '-- comment'                                                             || chr(10) ||
      '/* comment */'
    );
    Query OK, 0 rows affected (0.612 sec)
    

    Where:

    • create or replace package arithmetic as defines a package named arithmetic.
    • function add(a number, b number) return number defines an add function that accepts two number parameters and returns a number result.
    • function div(a number, b number) return number defines a div function that accepts two number parameters and returns a number result.
    • end arithmetic ends the package definition.
    • -- comment is a single-line comment.
    • /* comment */ is a multi-line comment.

    The wrapped code will be an unreadable string, similar to the following example (the actual output may vary depending on the version and environment):

    BEGIN
      DBMS_DDL.CREATE_WRAPPED('package body "SCHEMA_NAME"."ARITHMETIC" is
      function "ADD"(a in number, b in number) return number is
      begin
        return a + b;
      end;
      function "SUB"(a in number, b in number) return number is
      begin
        return a - b;
      end;
      function "MUL"(a in number, b in number) return number is
      begin
        return a * b;
      end;
      function "DIV"(a in number, b in number) return number is
      begin
        if b = 0 then
          raise value_error;
        else
          return a / b;
        end if;
      end;
    end "ARITHMETIC";');
    END;
    /
    

    Notice

    The actual wrapped output will be unreadable binary or encrypted text. The example above is for illustration only.

    Contact Us