Database Administrator (DBA) Question: Download Database Administrator (DBA) PDF

Shall we create procedures to fetch more than one record?

Tweet Share WhatsApp

Answer:

Yes. We can create procedures to fetch more than a row. By using CURSOR commands we could able to do that.
Ex:
CREATE OR REPLACE PROCEDURE myprocedure IS
CURSOR mycur IS select id from mytable;
new_id mytable.id%type;
BEGIN
OPEN mycur;
LOOP
FETCH mycur INTO new_id;
exit when mycur%NOTFOUND;
–do some manipulations–
END LOOP;
CLOSE mycur;
END myprocedure;
In this example iam trying to fetch id from the table mytable. So it fetches the id from each record until EOF.

(EXIT when mycur%NOTFOUND-is used to check EOF.

Download Database Administrator (DBA) PDF Read All 253 Database Administrator (DBA) Questions
Previous QuestionNext Question
Diffrence between a “where” clause and a “having” clausDo View contain Data?