Database Administrator (DBA) Question:
Download Questions PDF

Shall we create procedures to fetch more than one record?

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) Interview Questions And Answers PDF

Previous QuestionNext Question
Diffrence between a “where” clause and a “having” clausDo View contain Data?