Package specification, PL-SQL Programming

Assignment Help:

The Package Specification

The package specifications contain the public declarations. The scopes of these declarations are local to your database representation and global to the package. Therefore, the declared items are available from your application and from anyplace in the package. The figure describes the scoping.

1386_package specification.png

Figure: Package Scope

The specification lists the package resources accessible to the applications. All the information that your application require to use the resources is in the specification. For illustration, the declaration below shows that the function named the fac takes one argument of the type INTEGER and returns a value of type INTEGER:

FUNCTION fac (n INTEGER) RETURN INTEGER; -- returns n!

That is all the information you require to call the function. You do not require to consider its underlying implementation (whether it is recursive or iterative for illustration). The subprograms and cursors only have an underlying implementation or definition. Therefore, if a specification declares only the constants, types, variables, exceptions, and call specifications, the package body is unessential. Consider the bodiless package which is as shown below:

-- a bodiless package

CREATE PACKAGE trans_data AS

TYPE TimeRec IS RECORD (

minutes SMALLINT,

hours SMALLINT);

TYPE TransRec IS RECORD (

category VARCHAR2,

account INTEGER,

amount REAL,

time_of TimeRec);

minimum_balance CONSTANT REAL := 10.00;

number_processed INTEGER;

insufficient_funds EXCEPTION;

END trans_data;

The package trans_data requires no body as the constants, types, variables, and the exceptions do not have an underlying implementation. These packages define the global variables-usable by the subprograms and database triggers-that persist throughout a session.


Related Discussions:- Package specification

Parameter and keyword description - insert statement, Parameter and Keyword...

Parameter and Keyword Description:   table_reference: This identifies a table or view which should be available when you execute the INSERT statement, and for that you sho

EXCEPTION handling, set serveroutput on declare a number(5); b numb...

set serveroutput on declare a number(5); b number(5); c number(5); begin a:=&a; b:=&b; c:=a/b; dbms_output.put_line(c); exception when zero_divide then d

Using forall statement - bulk bind performance improvement, Using the FORAL...

Using the FORALL Statement The keyword FORALL instruct the PL/SQL engine to bulk-bind input collections before sending them all to the SQL engine. Though the FORALL statement

Wrapping and unwrapping in sql, Wrapping and unwrapping in SQL Operato...

Wrapping and unwrapping in SQL Operators WRAP and UNWRAP in connection with attributes whose declared types are tuple types. Example shows how extension and projection can be

Sql query on hospital database, Perform the following queries on the Hospit...

Perform the following queries on the Hospital1.DB using SQL Anywhere (START EARLY!). a. Which patients have purchased the drug "Tylenol"? List the names and addresses. Arrange the

Using for update, Using FOR UPDATE If you declare a cursor which will ...

Using FOR UPDATE If you declare a cursor which will be referenced in the CURRENT OF clause of an UPDATE or DELETE statement, you should use the FOR UPDATE clause to obtain an

Example of group by and collect operator, Example of GROUP BY and COLLECT O...

Example of GROUP BY and COLLECT Operator Example: Using GROUP BY and COLLECT to obtain C_ER2 SELECT CourseId, CAST ( COLLECT (ROW (StudentId, Mark)) AS ROW (Studen

Count operator in sql, Count Operator in SQL Example: Counting the stu...

Count Operator in SQL Example: Counting the students who have scored more than 50 in some exam (SELECT COUNT (*) FROM (SELECT DISTINCT StudentId FROM EXAM_MARK WHE

Triggers, At times, customers make mistakes in submitting their orders and ...

At times, customers make mistakes in submitting their orders and call to cancel the order. Brewbean’s wants to create a trigger that automatically updates the stock level of all pr

Overloading method in pl/sql, Overloading: Similar to packaged subprog...

Overloading: Similar to packaged subprograms, methods of the same type can be overloaded. That is, you can use similar name for various methods if their formal parameters diff

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd