What is pl/sql tables?

Answer Posted / bikash khuntia

Features of PL/SQL tables are as follows –

1) It is a composite data type.
2) They are modeled as similar to database tables, but they
are not permanent tables. So they can be created and
manipulated only in a PL SQL block.
3) They can have only one column but any data type
4) It will have a primary key which is compulsory for the
reference of values
5) There is no name to the column and primary key
6) The data type of the primary key is BINARY_INTEGER.
BINARY_INTEGER is a special data type which can be
given only to the column of PL/SQL table for it’s indexing
purpose to store and retrieve values.
Range of binary_integer is -2147483647 to 2147483647
7) Size is unconstrained (Table size grows as the rows are
added to the table).
8) Can visualize a Pl/SQL table as a single dimensional
vertical array, which can hold unlimited elements.
Suitable for storing and displaying the values of one
column of a table given by a cursor.


Example of PL SQL Table –

Each name from the emp table is given to the vname plsql
table by using cursor. Then those names from vname table
are displayed .

Declare
Type nametable IS TABLE OF CHAR(10) INDEX BY
BINARY_INTEGER;
/*Creating variable vname of nametable type.*/
vname nametable;
Cursor cf is select ename from emp;
i number;
/*i is for the loop and vrows is for displaying the
total names from the vname table*/
Begin
Open cf;
i := 1;
Loop
Fetch cf into vname(i);
/*Transferring each ename into vname table*/
Exit when cf%NotFound;
i := i+1;
End Loop;
Close cf;


/*Now retrieving the names from the vname plsql table using
for loop.*/
For n in 1 .. vname.count
Loop
dbms_output.put_line('Name is '||vname(n));
End Loop;
End;

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is a composite primary key ? : Sql dba

574


What is a boolean in sql?

518


What is cascade in sql?

554


What is a join query?

544


Can we use delete in merge statement?

510






What is union and union all keyword in sql and what are their differences?

568


how many ways to get the current time? : Sql dba

520


What is a sql trace file?

542


Can a view be mutating? If yes, then how?

568


What is a parameter query?

618


What is pl sql commands?

552


How would you convert date into julian date format?

587


What is optimistic concurrency control? : Transact sql

539


How many tables can a sql database have?

526


What are character functions in sql?

488