Oracle PL/SQL Tutorial/System Packages/DBMS DDL

Материал из SQL эксперт
Перейти к: навигация, поиск

Uses DBMS_DDL.CREATE_WRAPPED to obfuscate PL/SQL source

SQL>
SQL>
SQL>
SQL> CREATE TABLE myTable (
  2                             myID NUMBER(10) PRIMARY KEY,
  3                             myCode VARCHAR2(10 CHAR) NOT NULL,
  4                             region VARCHAR2(30 CHAR) NOT NULL,
  5                             country VARCHAR2(30 CHAR) NOT NULL);
Table created.
SQL> INSERT INTO myTable (myID, myCode, region, country)
  2  VALUES (1, "AKL", "Auckland", "NEW ZEALAND");
1 row created.
SQL>
SQL>
SQL> DECLARE
  2  v_procedure VARCHAR2(32767);
  3  BEGIN
  4    v_procedure := "CREATE OR REPLACE PROCEDURE create_wrapped_test "
  5    ||"IS "
  6    ||"   v_myCodes myTable.myCode%TYPE; "
  7    ||" "
  8    ||"   CURSOR airport_cur IS "
  9    ||"      SELECT myCode"
 10    ||"        FROM myTable"
 11    ||"        ORDER BY myCode;"
 12    ||" "
 13    ||"BEGIN "
 14    ||"   FOR y IN airport_cur LOOP "
 15    ||"      DBMS_OUTPUT.PUT_LINE(""Airport Code: ""||y.myCode);"
 16    ||"   END LOOP;"
 17    || "END;";
 18
 19    SYS.DBMS_DDL.CREATE_WRAPPED(v_procedure);
 20
 21  END;
 22  /
PL/SQL procedure successfully completed.
SQL>
SQL>
SQL>
SQL> SELECT text
  2  FROM user_source
  3  WHERE name = "CREATE_WRAPPED_TEST";
TEXT
------------------------------------------------------------------------------------------------------------------------
PROCEDURE create_wrapped_test wrapped
a000000
b2
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
7
130 10b
14sbBa4nRvMfcC4CwQzOuLJOzQMwg1zQr54VfHRAEIlxkSMxHbResWCIfgyhXmOwh9KP3mV6
ue7N1Bu6yshPJJosBnV0g93nQMyZ6Fv2wVAbNZZpEoUyrkXJgFb6yOkoCicnlkM8e/L1TRs2
WXCu5A/XwL3ZQy0170tsH1viWc3RqirjYmXDUoA+TaUrv4J10OmFTjPghF1vGSs7ro7bRD7H
wYrLrgI/KE8/zqwpT2SZjoYEv7VusA9LA8fIl9Z75KbcK2nt

SQL>
SQL>
SQL> SET SERVEROUTPUT ON
SQL>
SQL> EXEC create_wrapped_test
Airport Code: AKL
PL/SQL procedure successfully completed.
SQL>
SQL>
SQL>
SQL> drop table myTable;
Table dropped.