Retriving Multiple Records

Why PL/SQL does not support retriving multiple records?

Questions by bmsrao

Editorial / Best Answer

promisinganuj  

  • Member Since Sep-2009 | Sep 13th, 2009


Retriving multiple records is a basic feature of SQL where we fetch the data using SELECT statement.
SELECT *
  FROM emp;
This itself gives us multiple records. There is no additional feature required to do the same in PL/SQL.
At the same time, PL/SQL goes one step further and enable us to process these fetched rows one by one (unlike the update statements which updates all the rows selected).
There are several options for fethcing data in different PL/SQL constructs:
1. Using Ordinary Cursor
2. Using Ref Cursor
3. Using PL/SQL bulk collect
4. Using PL/SQL arrays

But the important thing here is that irrespective of the way we fetch the data, we act upon them row-by-row.

Showing Answers 1 - 10 of 10 Answers

Mad Hatter

  • Nov 4th, 2008
 

Multiple records at a time could be retreved in PL/SQL using BULK COLLECT.
To do that you define PL/SQL table, and load it using
SELECT ... BULK COLLECT INTO <pl/sql table>
FROM ..

Optionaly could be used LIMIT - to limit the number of records retreved at a time, like

SELECT ... BULK COLLECT INTO <pl/sql table>
FROM ..
LIMIT 1000

Retriving multiple records is a basic feature of SQL where we fetch the data using SELECT statement.
SELECT *
  FROM emp;
This itself gives us multiple records. There is no additional feature required to do the same in PL/SQL.
At the same time, PL/SQL goes one step further and enable us to process these fetched rows one by one (unlike the update statements which updates all the rows selected).
There are several options for fethcing data in different PL/SQL constructs:
1. Using Ordinary Cursor
2. Using Ref Cursor
3. Using PL/SQL bulk collect
4. Using PL/SQL arrays

But the important thing here is that irrespective of the way we fetch the data, we act upon them row-by-row.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions