What will the Output for this Coding> Declare Cursor c1 is select * from emp FORUPDATE; Z c1%rowtype;Begin Open C1;Fetch c1 into Z;Commit;Fetch c1 in to Z;end;

Showing Answers 1 - 8 of 8 Answers

vivek tyagi

  • Aug 17th, 2006
 

by declaring this cursor we can update the table emp through z,means wo not need to write table name for updation,it may be only by "z".

  Was this answer useful?  Yes

fli3

  • Aug 18th, 2006
 

No error. Everthing is fine. Once commit, the only thing happened is the table got unlocked.

  Was this answer useful?  Yes

divya

  • Aug 23rd, 2006
 

The block  will fail with error:

ORA-01002: fetch out of sequence
This is because  in for update cursors , since rows are
 locked by the query , one has to make  sure that the crrsor is closed before
 commmiting.
 

Pankaj Gauba

  • Sep 13th, 2006
 

No error. Everthing is fine. Once commit, the only thing happened is the table got unlocked.

Table is locked until the table is updated or deleted

  Was this answer useful?  Yes

Raghavendra

  • Nov 19th, 2006
 

NO ERROR..

  Was this answer useful?  Yes

Declare
Cursor c1 is select * from emp FORUPDATE;
Z c1%rowtype;
Begin
Open C1;
Fetch c1 into Z;
Commit;
Fetch c1 in to Z;
end;

 SQL> start e1
Declare * ERROR at line 1: ORA-01002: fetch out of sequence ORA-06512: at line 8
Reason: This error means that a fetch has been attempted from a cursor which is no longer valid.
Here the main reason of this error is
"the cursor has been opened with the FOR UPDATE clause, fetching after a COMMIT has been issued will returning the error.

Action: Do not issue a COMMIT inside a fetch loop for a cursor that has been opened FOR UPDATE

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