Shall we create procedures to fetch more than one record?
Submitted by: AdministratorYes. 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.
Submitted by: Administrator
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.
Submitted by: Administrator
Read Online Database Administrator (DBA) Job Interview Questions And Answers
Top Database Administrator (DBA) Questions
☺ | Name three advisory statistics you can collect. |
☺ | How would you determine who has added a row to a table? |
☺ | What are the ways to monitor the performance of the report? |
☺ | What DBA activities did you to do today? |
☺ | What is the maximum no of chars the parameter can store? |
Top Databases Programming Categories
☺ | RDBMS Interview Questions. |
☺ | SQL Interview Questions. |
☺ | SSRS Interview Questions. |
☺ | Sybase Interview Questions. |
☺ | Database Administrator (DBA) Interview Questions. |