Header Ads Widget

Responsive Advertisement

Module 06: Working with Composite Data Types

Working with Composite Data Types 


01. What is Composite Data Types?

Can hold multiple values (unlike scalar types)


02. What are the types of Composite Data Types?

Are of two types:

a. PL/SQL records.

b. PL/SQL collections.


03. Why Use Composite Data Types?

Composite Data Types:

a. You have all the related data as a single unit.

b. You can easily access and modify data.

c. Data is easier to manage, relate, and transport if it is composite.

d. An analogy is having a single bag for all your laptop components rather than a separate bag for each component.


04. When you can be use PL/SQL Records or Collections?

Use PL/SQL Records:

a. Use PL/SQL records when you want to store values of different data types but only one occurrence at a time.

b. Use PL/SQL collections when you want to store values of the same data type.


05. What is PL/SQL Records?

Records:

a. Must contain one or more components (called fields) of any scalar, RECORD, or INDEX BY table data type.

b. Are user-defined and can be a subset of a row in a table.

c. Treat a collection of fields as a logical unit.

d. Are convenient for fetching a row of data from a table for processing.


06. Write down about %ROWTYPE Attribute.

%ROWTYPE Attribute:

a. Declare a variable according to a collection of columns in a database table or view.

b. Prefix %ROWTYPE with the database table or view.

c. Fields in the record take their names and data types from the columns of the table or view.


07. Write down advantages of using the %ROWTYPE Attribute.

Advantages of Using the %ROWTYPE Attribute:

a. The number and data types of the underlying database columns need not be known—and, in fact, might change at run time.

b. The %ROWTYPE attribute is useful when you want to retrieve a row with:

i. The SELECT*statement.

ii. Row-level INSERT and UPDATE statements.


08. What is PL/SQL collections? What are the types of PL/SQL collections?

PL/SQL collections: Collections are used to treat data as a single unit.

Collections are of three types:

a. Associative array.

b. Nested table.

c. VARRAY.


09. What is Associative Arrays?

An associative array is a type of PL/SQL collection. It is a composite data type, and is user defined. Associative arrays are sets of key-value pairs. They can store data using a primary key value as the index, where the key values are not necessarily sequential. Associative arrays are also known as INDEX BY tables.


10. Write down the Using INDEXBY Table Methods.

An INDEX BY table method is a built-in procedure or function that operates on an associative array and is called by using the dot notation.

Syntax: table_name, method_name [(parameters)]

The following methods make associative arrays easier to use:

a. EXISTS

b. COUNT

c. FIRST

d. LAST

e. PRIOR

f. NEXT

g. DELET


11. What is Nested Tables?

A nested table holds a set of values. In other words, it is a table within a table. Nested tables are unbounded; that is, the size of the table can increase dynamically.


12. What is Varrays?

Variable-size arrays, or varrays, are also collections of homogeneous elements that hold a fixed number of elements. 

Post a Comment

0 Comments