How to avoid using cursors? What to use instead of cursor and in what cases to do so?

Questions by moviefan456

Showing Answers 1 - 24 of 24 Answers

Venkat

  • Sep 21st, 2006
 

I think the answer is:

If your select statement retruns only one value, you can avoid using cursor:
for instance:

select fname into v_fname
from emp where empno = 10;

(here assueme that the empno is PK)

in your procedure or package or function you can declare the variable v_fname and directly use the above sql statement instead of declaring a cursor,opening, ...

Thanks.

Venkat

  Was this answer useful?  Yes

Venkat9999

  • Sep 21st, 2006
 

I think the answer is:

If your select statement retruns only one value, you can avoid using cursor:
for instance:

select fname into v_fname
from emp where empno = 10;

(here assueme that the empno is PK)

in your procedure or package or function you can declare the variable v_fname
and directly use the above sql statement instead of declaring a cursor,opening,
...

Venkat

  Was this answer useful?  Yes

Jagadish V

  • Nov 24th, 2006
 

if you need to perform manipulations from the output of the select statement which results multiple rows ,the cursor need to be used.

  Was this answer useful?  Yes

Tanveer Islam Siddiqui

  • Nov 24th, 2006
 

U have 2 options to do it..

1st) Use Pl/SQL Table...

2nd) Create Temporary Table and use it in place of Table...

  Was this answer useful?  Yes

Thulasidas

  • Nov 26th, 2006
 

Well there may be several ways for not to use a cursor. But a good programming practice suggests the use of cursors as much as possible for performance and efficiency purpose.

  Was this answer useful?  Yes

srinivas

  • Nov 29th, 2006
 

insted of using cursor we will use attribute data types %type and %rowtype to load data in pl/sql

  Was this answer useful?  Yes

KSPRADEEP

  • Oct 17th, 2012
 

Yes we can ..
Instead of cursor we using bulk collection or bulk binding or using %type and %rowtype

  Was this answer useful?  Yes

Ashish

  • Jun 12th, 2014
 

You can use MERGE statements in Oracle to avoid looping through Conventional cursors. It will save lot of time

  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