0% found this document useful (0 votes)
49 views

PL SQL

PL/SQL tables provide an in-memory array structure for storing and accessing data. They are indexed by binary integers and do not persist beyond the current session. PL/SQL tables are declared with a TYPE statement defining the structure, followed by declaring actual table variables of that type. Rows in a PL/SQL table are referenced using the table name and index number. Various attributes like COUNT, FIRST, and DELETE can provide information about or modify rows in a PL/SQL table.

Uploaded by

sumit3110
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

PL SQL

PL/SQL tables provide an in-memory array structure for storing and accessing data. They are indexed by binary integers and do not persist beyond the current session. PL/SQL tables are declared with a TYPE statement defining the structure, followed by declaring actual table variables of that type. Rows in a PL/SQL table are referenced using the table name and index number. Various attributes like COUNT, FIRST, and DELETE can provide information about or modify rows in a PL/SQL table.

Uploaded by

sumit3110
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

PL/SQL TABLES

PL/SQL tables are PL/SQL’s way of providing arrays. Arrays are like tem-porary

tables in memory and thus are processed very quickly. It is impor-tant

for you to realize that they are not database tables, and DML

statements cannot be issued against them. This type of table is indexed

by a binary integer counter (it cannot be indexed by another type of

number) whose value can be referenced using the number of the index.

Remember that PL/SQL tables exist in memory only, and therefore don’t

exist in any persistent way, disappearing after the session ends.

A PL/SQL TABLE DECLARATION

There are two steps in the declaration of a PL/SQL table. First, you must

define the table structure using the TYPE statement. Second, once a table

type is created, you then declare the actual table.

FOR EXAMPLE

DECLARE

-- Table structure definition

TYPE NameType IS TABLE OF

Customer.name_name%TYPE

INDEX BY BINARY_INTEGER;

-- Create the actual table

CnameTab NameType;

KnameTab NameType;

BEGIN
NULL; -- ...
END;
REFERENCING AND MODIFYING PL/SQL

TABLE ROWS

In order to specify a particular row in a PL/SQL table, you must name the
table and the index.
PL/SQL TABLE ATTRIBUTES

Here are seven PL/SQL table attributes you can use to gain information

about a PL/SQL table or to modify a row in a PL/SQL table:

• DELETE—Deletes rows in a table.

• EXISTS—Return TRUE if the specified entry exists in the table.

• COUNT—Returns the number of rows in the table.

• FIRST—Returns the index of the first row in the table.

• LAST—Returns the index of the last row in the table.

• NEXT—Returns the index of the next row in the table after the

specified row.

• PRIOR—Returns the index of the previous row in the table be-fore

the specified row.

PL/SQL table attributes are used with the following syntax:

If you declare a PL/SQL table named t_customer then you get a rowcount

for the table as follows:

v_count := t_customer.count;

The DELETE and EXISTS attributes function differently than the other attributes.

These two generally operate on one row at a time, so you must

add the following syntax:

.([,])

t.customer.delete deletes all rows from the t_customer table, whereas

t_customer.delete(15) deletes the fifteenth row of the t_customer table.

Likewise, t_customer.exists(10) returns a value of true if there is a one-hundredth row and


a value of false if there is not.

The EXISTS attribute can be used to determine if a particular index value

exists in the PL/SQL table or not.

You might also like