What would be the o/p for this ....declarecursor c1 is select * from employees;emp_rec c1%rowtype;beginopen c1;delete from employees;loopfetch c1 into emp_rec;exit when c1%notfound;end loop;close c1;end;tell me what is active set ?why you need cursors?and what is going to happen when you use for update clause in cursor declarationwhy use nowait clause what is its use

Questions by basukolur014   answers by basukolur014

Showing Answers 1 - 2 of 2 Answers

Rama Krishna,Y

  • Aug 21st, 2006
 

Hi Friend!! If you want to use the entire tale data from table in PL/SQL programing block,you have to store the entire data in a temp buffer variable .. to syntronize that operation Oracle supports Cursor Variables..If you want to Lock the records in the table while u perofrming any DML you need to lock that table of rows..so you must use "for update" clasueThe output for the above program last record will be fetched finally and can be used ..Thanks&RegdsRamki,TCS,Hyd,9989018508

  Was this answer useful?  Yes

Sheetal

  • Aug 24th, 2006
 

Hi,

Your program will delete all rows from the table. If you print output after fetch from the cursor it will show all rows those where selected in the cursors.

When the cursor was created u selected all rows from the table. Then u opened the cursor that is active set is defined then u delete all rows from table. But as cusor's active set is already defined, after fetch the output will be rows in the cursor.

If you would have reopened the cursor after deleting all rows from table then the cursor would be also blank.

For update is used to modify and delete rows in the cursor. For update is the lock so that no other user changes the rows in the cursor when u r changing it.

Nowait means before u lock the rows may be some other user had the lock on same rows in that case u will be in hang state till that user releases lock. Nowait clause will display error message to if some other user has the lock.

Hope this information helps you.

  Was this answer useful?  Yes

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