Steps:
1. Create a object type with required column attributes
2. Create
a nested table based on the object created
3. Create
a function that returns a nested table type
Explanation:
Why object type?
·
Object will give the
ability to hold the multiple attributes like
First_name, last_name,
dept_name, salary..etc
Nested table:
·
Nested table will be
perfect to store the fetched data.
·
Nested table is made
from object type, so it will hold multiple columns data in a single key value
pair.
Example:
First_name, last_name, dept_name, salary
Function:
· Function can returns
multiple values through the object type and nested table type.
Example:
Following function can return Multiple values (Ename,job,sal)
Step
1: Object Creation
Step
2: Nested table creation based on the object
Step 3: Function
Calling method:
Select * from table (fun_ret_val(100));
Here,
No database objects in the function so we can easily call the function in select statement.
Following function for
return all employee records:
Calling method:
Select * from
table (fun_ret_val);
Bulk
collect:
·
This is used to fetch the many rows at once and place them in a collection.
No comments:
Post a Comment