Created
March 26, 2021 22:07
-
-
Save KrashLeviathan/5ae3132d26e7cd29b0333fa7d5df617b to your computer and use it in GitHub Desktop.
EXAMPLE: Wrapping (obfuscating) a PL/SQL package body
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Documentation: https://docs.oracle.com/en/database/oracle/oracle-database/18/lnpls/plsql-source-text-wrapping.html | |
-- One thing to keep in mind (that I didn't find in the docs) is that later, if you want to | |
-- update the variables in the package spec and re-compile the spec and the wrapped body, you can do | |
-- that in SQL Developer without having to re-wrap the original source code. Just open up | |
-- the wrapped body and click the Compile button. | |
-- Create package specification without obfuscation | |
create or replace PACKAGE HELLO_PKG AS | |
g_person_to_greet varchar2(8) := 'Nate'; | |
procedure hello; | |
END HELLO_PKG; | |
-- Using the DBMS_DDL package is one way to wrap the body. | |
-- There's also command line utilities. | |
DECLARE | |
l_str VARCHAR2(32000); | |
BEGIN | |
l_str := q'~ | |
CREATE OR REPLACE | |
PACKAGE BODY HELLO_PKG AS | |
procedure hello AS | |
BEGIN | |
dbms_output.put_line('Hello ' || g_person_to_greet || '!'); | |
END hello; | |
END HELLO_PKG;~'; | |
dbms_ddl.create_wrapped(l_str); | |
END; | |
/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment