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) |
|
| CREATE_WRAPPED(DDL DBMS_SQL.VARCHAR2A, LB PLS_INTEGER, UB PLS_INTEGER) |
|
| CREATE_WRAPPED(DDL DBMS_SQL.VARCHAR2S,LB PLS_INTEGER,UB PLS_INTEGER) |
|
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 asdefines a package named arithmetic.function add(a number, b number) return numberdefines anaddfunction that accepts two number parameters and returns a number result.function div(a number, b number) return numberdefines adivfunction that accepts two number parameters and returns a number result.end arithmeticends the package definition.-- commentis 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.