1. Overview
This document is about how to wrap the PLSQL code in oracle.
2. Technologies and Tools Used
The following technologies have been used to wrap the PLSQL code.
- Command Prompt
- Toad
3. Use Case
Let us have the requirement on to wrap the PLSQL code in oracle.
4. Steps with Screenshot
Overview of Wrapping
Wrapping is the process of hiding PL/SQL source code. Wrapping helps to protect your source code by making it more difficult for others to view it.
You can wrap PL/SQL source code with either the wrap utility or using Toad.
Step 1:
Wrapping PLSQL code with wrap utility:
The wrap utility processes an input SQL file and wraps only the PL/SQL units in the file, such as a package specification, package body, function, procedure, type specification, or type body. It does not wrap PL/SQL content in anonymous blocks or triggers or non-PL/SQL code.
The wrap utility need not connect to Oracle Database (in fact, it cannot connect to Oracle Database).
To run the wrap utility, enter the wrap command at your operating system prompt using this syntax (with no spaces around the equal signs):
wrap iname=input_file [ oname=output_file ]
input_file is the name of a file containing SQL statements, which you typically run using SQL*Plus. If you omit the file extension, .sql is assumed. For example, these commands are equivalent:
wrap iname=/mydir/myfilewrap iname=/mydir/myfile.sql
You can specify a different file extension. For example:
wrap iname=/mydir/myfile.src
output_file is the name of the wrapped file to be created. If you omit the oname option, output_file has the same name as input_file, but with the extension .plb. For example, these commands are equivalent:
wrap iname=/mydir/myfilewrap iname=/mydir/myfile.sql oname=/mydir/myfile.plb
You can specify a different output file name and extension. For example:
wrap iname=/mydir/myfile oname=/yourdir/yourfile.out
Example :
Step 2:
Wrapping PLSQL Code Using Toad Example:
- Click on the Menu Utilities > Wrap Utility.
- For the Input File field, provide the source file name with the path (use the browse button).
- Then click on Wrap Code (green) button to wrap the code.
- To Save the Output File field, provide the file name with the path.
- Click on Save Button.
Example:
Guidelines for Wrapping:
- Wrap only the body of a package or ADT, not the specification.
- Wrap code only after you have finished editing it.
- Before distributing a wrapped file, view it in a text editor to ensure that all important parts are wrapped.
- Wrapping is not a secure method for hiding passwords or table names.
- This allows other developers to see the information they must use the package or type, but prevents them from seeing its implementation.
- You cannot edit PL/SQL source code inside wrapped files. Either wrap your code after it is ready to ship to users or include the wrapping operation as part of your build environment.
- To change wrapped PL/SQL code, edit the original source file and then wrap it again.
Limitations of Wrapping:
- Wrapping does not hide the source code for triggers.
- Wrapping a PL/SQL unit helps prevent most users from examining the source code, but might not stop all of them.
- To hide the workings of a trigger, write a one-line trigger that invokes a wrapped subprogram
- Wrapping does not detect syntax or semantic errors.