![cursors pack cursors pack](https://i2.wp.com/uxthemepatcher.com/pic/Windows_11_Cursors_Concept.png)
Subsequent invocations of other subprograms in same the package require no disk I/O. The first time you invoke a package subprogram, Oracle Database loads the whole package into memory. (For the situations in which package public variables and cursors do not persist for the life of a session, see " Package State".) They let you maintain data across transactions without storing it in the database. They can be shared by all subprograms that run in the environment. Package public variables and cursors can persist for the life of a session.
#CURSORS PACK CODE#
You can change the implementation details without affecting the application interface.Īpplication users cannot develop code that depends on implementation details that you might want to change. Hiding the implementation details in the body has these advantages: Packages let you share your interface information in the package specification, and hide the implementation details in the package body. You need not fully define the package bodies until you are ready to complete the application. Next, you can compile standalone subprograms that reference the packages. You can code and compile specifications without their bodies. When designing an application, all you need initially is the interface information in the package specifications. This practice aids application development. You can make each package easy to understand, and make the interfaces between packages simple, clear, and well defined.
![cursors pack cursors pack](https://i.pinimg.com/originals/f8/a7/61/f8a76186307c58ac095d43d264dffb35.jpg)
Packages let you encapsulate logically related types, variables, constants, subprograms, cursors, and exceptions in named PL/SQL modules. Packages support the development and maintenance of reliable, reusable code with the following features:
![cursors pack cursors pack](https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/i/52a5c175-1b7c-4bee-871c-bc490fa2c4d1/dgs6le-f0160484-d5d4-4902-bde9-e341241d32fa.png)
To restrict use of the package to the intended units, you list them in the ACCESSIBLE BY clause in the package specification. You create a utility package to provide services to some, but not all, PL/SQL units in the same schema. Therefore, you omit the ACCESSIBLE BY clause from the API package specification and include it in each helper package specification, where you specify that only the API package can access the helper package. You want clients to have access to the API, but not to the helper packages. You implement a PL/SQL application as several packages-one package that provides the application programming interface (API) and helper packages to do the work. You use this clause in situations like these: The ACCESSIBLE BY clause of the package specification lets you specify a white list of PL/SQL units that can access the package. The AUTHID clause of the package specification determines whether the subprograms and cursors in the package run with the privileges of their definer (the default) or invoker, and whether their unqualified references to schema objects are resolved in the schema of the definer or invoker. In either the package specification or package body, you can map a package subprogram to an external Java or C subprogram by using a call specification, which maps the external subprogram name, parameter types, and return type to their SQL counterparts. You can change the body without changing the specification or the references to the public items therefore, you can think of the package body as a black box. Finally, the body can have an initialization part, whose statements initialize variables and do other one-time setup steps, and an exception-handling part. The body can also declare and define private items that cannot be referenced from outside the package, but are necessary for the internal workings of the package. The body must define queries for public cursors and code for public subprograms. If the public items include cursors or subprograms, then the package must also have a body. A package is compiled and stored in the database, where many applications can share its contents.Ī package always has a specification, which declares the public items that can be referenced from outside the package. A package is a schema object that groups logically related PL/SQL types, variables, constants, subprograms, cursors, and exceptions.