Do you know the easiest way to create a package in Oracle?
There are two steps in creating the package. I am using Toad as an Oracle Developer Software for accessing the database.

After the connection is established, we will see this screen where we need to code for creating a package.

First, we need to create a specification for the package.
- CREATEORREPLACEPACKAGE SCHEMA1.PACKAGE1 AS
- PROCEDUREGET_PROCEDURE1 (PVARIABLE1 VARCHAR2,C_OUTPUT OUTSYS_REFCURSOR );
- PROCEDUREGET_PROCEDURE2 (PVARIABLE1 VARCHAR2,PVARIABLE2 VARCHAR2 C_OUTPUT OUTSYS_REFCURSOR );
- END; /

In this specification, we declare a procedure prototype. And in the body, we define the functionality of the package name and procedure. Compiling specification is in Toad.
Then, we need to create the package body.
Then, we need to create the package body.
- CREATEORREPLACEPACKAGE BODY SCHEMA1.PACKAGE1 AS
- PROCEDUREGET_PROCEDURE1 (PVARIABLE1 VARCHAR2, C_OUTPUT OUTSYS_REFCURSOR )
- IS
- BEGIN
- OPENC_OUTPUT FOR
- SELECT* FROMTABLE1 WHEREVARIABLE1=PVARIABLE1 ;
- END;
- PROCEDUREGET_PROCEDURE2 (PVARIABLE1 VARCHAR2,PVARIABLE2 VARCHAR2 C_OUTPUT OUTSYS_REFCURSOR )
- IS
- BEGIN
- OPENC_OUTPUT FOR
- SELECT* FROMTABLE2 WHEREVARIABLE1=PVARIABLE1 ANDVARIABLE1 =PVARIABLE2 ;
- END;
- END; /

In the package body, we will define the procedure.
Hence, the package is ready to use after compilation.

Join the conversation! Your thoughts help the community grow.