Data abstraction, PL-SQL Programming

Data Abstraction

The Data abstraction extracts the important properties of data while ignoring the not necessary details. Once you design a data structure, you can fail to remember the details and focus on designing algorithms that manipulate the data structure.

Collections

The collection types TABLE and VARRAY permit you to declare nested tables and variable-size arrays (varrays in short). A collection is an ordered group of elements, all of the similar type. Every element has a unique subscript that determines its place in the collection.

To reference an element, use the standard subscripting syntax. For e.g., the following call references the 5th element in the nested table returned by the function new_hires:

DECLARE

TYPE Staff IS TABLE OF Employee;

staffer Employee;

FUNCTION new_hires (hiredate DATE) RETURN Staff IS

BEGIN ... END;

BEGIN

staffer := new_hires('10-NOV-98')(5);

...

END;

The Collections work like an array found in most third-generation programming languages. The collections can also be passed as parameters. And hence, you can use them to move columns of data into and out of database tables or between the client-side applications and stored subprograms.

Records

You can use the %ROWTYPE attribute to declare a record that shows a row in a table or a row fetched from a cursor. Although, with a user-defined record, you can declare fields of your own. The Records contain exclusively named fields that can have different datatypes. Assume that you have different data about an employee like name, salary, & hire date. These items are not similar in type but logically related. Records containing a field for each item treat the data as a logical unit. Consider the example shown below:

DECLARE

TYPE TimeRec IS RECORD (hours SMALLINT, minutes SMALLINT);

TYPE MeetingTyp IS RECORD

(

date_held DATE,

duration TimeRec, -- nested record

location VARCHAR2(20),

purpose VARCHAR2(50));

Remember that you can nest the records. That is, the record can be the component of another record.

Posted Date: 10/2/2012 1:49:29 AM | Location : United States







Related Discussions:- Data abstraction, Assignment Help, Ask Question on Data abstraction, Get Answer, Expert's Help, Data abstraction Discussions

Write discussion on Data abstraction
Your posts are moderated
Related Questions
Defining REF CURSOR Types To make cursor variables, you take 2 steps. At first, you define a REF CURSOR type, and then declare the cursor variables of that type. You can defin

Special cases of projection This section describes the identity projection, r {ALL BUT}, and the projection on no attributes, r { }, which yields TABLE_DUM when r is empty, ot

Explicit Cursors The set of rows returned by the query can include zero, one, or multiple rows, depending on how many rows meet your search criteria. Whenever a query returns

The SQL ‘CREATE TABLE' scripts for all the tables you have implemented. Note that your tables must correspond exactly to the ERD you have provided in 1. above, or you will lose ma

Explicit Cursors The set of rows returned by the query can include zero, one, or multiple rows, depending on how many rows meet your search criteria. Whenever a query returns

Control Structures The Control structures are the most important PL/SQL extension to the SQL. Not only does PL/SQL let you manipulate Oracle data, it lets you process the data

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

Example of ADD CONSTRAINT in SQL Example: Alternative formulation for MAX_ENROLMENTS ALTER TABLE IS_ENROLLED_ON ADD CONSTRAINT MAX_ENROLMENTS CHECK ((SELECT COUNT (*)

Predefined Exceptions The internal exception is raised implicitly whenever your PL/SQL program exceeds a system-dependent limit or violates an Oracle rule. Each & every Oracle

Declaring and Initializing Objects: An object type is once defined and installed in the schema; you can use it to declare the objects in any PL/SQL, subprogram, block or packa