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
How is data stored on a disk?
how to drop an existing table in mysql? : Sql dba
Can you call pl/sql package functions from within a fast formula?
Whis is not false in primary key?
What is clustered index in sql?
What packages(if any) has oracle provided for use by developers?
Can we insert data in view?
what is rollback? : Sql dba
how to enter binary numbers in sql statements? : Sql dba
How is indexing done in search engines?
What is difference between nchar and nvarchar?
What is materialized view. What are different methods of refresh?
what are date and time functions in mysql? : Sql dba
What is the difference among union, minus and intersect?
What is difference between pls_integer and integer?