Home » SQL & PL/SQL » SQL & PL/SQL » CURSORS
icon9.gif  CURSORS [message #205221] Thu, 23 November 2006 23:43 Go to next message
cutsmartprem
Messages: 62
Registered: November 2006
Member
I have seen this example in a book

CURSOR EMP_CUR IS
SELECT EMP_NAME,EMP_SAL FROM EMP_DET WHERE EMP_ID=1;


It is used in a explicit cursor. What is the need to fetch a single row using explicit cursor, the function or a procedure can imply the logic.

Also is it possible to move through the rows in the cursor without using a loop.

Thanks in advance
Re: CURSORS [message #205236 is a reply to message #205221] Fri, 24 November 2006 00:46 Go to previous messageGo to next message
moparthy99
Messages: 13
Registered: July 2006
Junior Member

Using the bulk collect into option to all rows from cursor with out any loop.for that we need define either index by tables or varrays.

If ur writing any pl/sql script means we reduced context swithes
reduced network traffic.if it is sql stmt it always hit DB.Only
performance issue


Re: CURSORS [message #205243 is a reply to message #205236] Fri, 24 November 2006 00:55 Go to previous messageGo to next message
vgs2005
Messages: 123
Registered: April 2005
Senior Member
CURSOR EMP_CUR IS
SELECT EMP_NAME,EMP_SAL FROM EMP_DET WHERE EMP_ID=1;

Quote:
What is the need to fetch a single row using explicit cursor

That is not really a common practice. But the code you see does not imply that it will return only 1 row or emp_id is a primary key. The table is EMP_DET not EMPLOYEE.
Re: CURSORS [message #205251 is a reply to message #205236] Fri, 24 November 2006 01:12 Go to previous messageGo to next message
cutsmartprem
Messages: 62
Registered: November 2006
Member
ya thanks for tat explanation

can u tel me how to spool the output of a query..

explain with example and tel the use of it
Re: CURSORS [message #205252 is a reply to message #205243] Fri, 24 November 2006 01:13 Go to previous messageGo to next message
cutsmartprem
Messages: 62
Registered: November 2006
Member
this will get only one row because emp_id is a primary of the

table emp_det;


thanks for that explanation
Re: CURSORS [message #205277 is a reply to message #205252] Fri, 24 November 2006 02:39 Go to previous messageGo to next message
vgs2005
Messages: 123
Registered: April 2005
Senior Member
Quote:
this will get only one row because emp_id is a primary of the

hmm.. frankly, I don't see any use putting it in a cursor. Simplest thing is to use INTO. To 'spool' (as in SQL term), you can try the 'SPOOL' command:
SQL>  spool my_log
SQL>  select * from Parent;

NAME                        AGE ADDRESS
-------------------- ---------- ----------
A                            19 here
B                            19 there
C                            19 near
D                            19 far

SQL> spool off;

To see the spool file:
SQL> ed my_log.lst

Here's some more info.
Re: CURSORS [message #205280 is a reply to message #205277] Fri, 24 November 2006 02:49 Go to previous messageGo to next message
cutsmartprem
Messages: 62
Registered: November 2006
Member
HEY REALLY THANKS FOR UR EXPLANATION

IT HELPS ME A LOT TO DO MY WORK


KIND OF U...
Re: CURSORS [message #205321 is a reply to message #205277] Fri, 24 November 2006 04:43 Go to previous message
moparthy99
Messages: 13
Registered: July 2006
Junior Member

Hi

I guiess same what u think.But only if use select into is implicit cursor but same implicit cursor converson into explicit cursor see the code
Previous Topic: How to use cursors
Next Topic: is it possible to install doskey like option in oracle?
Goto Forum:
  


Current Time: Sun Dec 08 07:41:41 CST 2024