Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Which is beter a cursor or a for loop?
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C2DBF5.0AC6B3E0
Content-Type: text/plain; charset="iso-8859-1"
Denham
The for loop is a lot easier to read. It can be a real pain scrolling to the top every time you want to see what such-and-such a cursor is doing. On the other hand, it can be a bit limiting in more 'advanced' situations - eg. you can't mess around with cursor%rowtype variables and you can't fetch from the cursor in more than one place.
Regards
David Lord
-----Original Message-----
Sent: 24 February 2003 08:39
To: Multiple recipients of list ORACLE-L
Hello,
I was just asked by one of our developers which is beter to use:-
a cursor or a for loop?
I must admit I am not sure....
Anyway the specific piece of code in discussion is similar to the following....
FOR X IN (SELECT X FROM TABLE_NAME WHERE COL1 = 'Something')) LOOP Do a whole lot of stuff in database here...... LOOP END;
I would guess that the cursor would follow similar execution criteria but
using
the cursor syntax.
Any ideas?
TIA
regards
Denham Eva
Oracle DBA
The real problem is not whether machines think but whether men do.
- B. F. Skinner
DISCLAIMER This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. No confidentiality or privilege is waived or lost by any mistransmission. If you receive this message in error, please immediately delete it and all copies of it from your system, destroy any hard copies of it and notify the sender. You must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient. TFMC, its holding company, and any of its subsidiaries each reserve the right to monitor and manage all e-mail communications through its networks.
Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorized to state them to be views of any such entity.
This e-mail message has been scanned for Viruses and Content and cleared by
MailMarshal - For more information please visit
<http://www.marshalsoftware.com> www.marshalsoftware.com
A member of the Hays plc group of companies. Hays plc is registered in England and Wales number 2150950. Registered Office Hays House Millmead Guildford Surrey GU2 4HJ.
------_=_NextPart_001_01C2DBF5.0AC6B3E0
Content-Type: text/html; charset="iso-8859-1"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>Which is beter a cursor or a for loop?</TITLE>
<META content="MSHTML 6.00.2716.2200" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=741430311-24022003><FONT face="Courier New"
size=2>Denham</FONT></SPAN></DIV>
<DIV><SPAN class=741430311-24022003><FONT face="Courier New"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=741430311-24022003><FONT face="Courier New" size=2>The for loop
is a lot easier to read. It can be a real pain scrolling to the top every
time you want to see what such-and-such a cursor is doing. On the other
hand, it can be a bit limiting in more 'advanced' situations - eg. you can't
mess around with cursor%rowtype variables and you can't fetch from the cursor in
more than one place.</FONT></SPAN></DIV>
<DIV><SPAN class=741430311-24022003><FONT face="Courier New"
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=741430311-24022003><FONT face="Courier New"
size=2>Regards</FONT></SPAN></DIV>
<DIV><SPAN class=741430311-24022003><FONT face="Courier New" size=2>David
Lord</FONT></SPAN></DIV>
<BLOCKQUOTE
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid">
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B> Denham Eva [mailto:EvaD_at_TFMC.co.za]<BR><B>Sent:</B> 24 February 2003 08:39<BR><B>To:</B> Multiple recipients of list ORACLE-L<BR><B>Subject:</B> Which is beter acursor or a for loop?<BR><BR></FONT></DIV> <P><FONT face=Arial size=2>Hello,</FONT> </P> <P><FONT face=Arial size=2>I was just asked by one of our developers which is beter to use:-</FONT> <BR><FONT face=Arial size=2>a cursor or a for loop?</FONT> <BR><FONT face=Arial size=2>I must admit I am not sure....</FONT> </P>
size=2> WHERE COL1 = 'Something'))</FONT> <BR><FONT face=Arial size=2> LOOP</FONT> <BR><FONT face=Arial
<P> <HR> </FONT></STRONG><STRONG><FONT face=Arial color=#0000a0size=2>DISCLAIMER</FONT> </STRONG>
<P></P>
<HR>
This e-mail message has been scanned for Viruses and Content and cleared by
<STRONG><FONT color=#ff8000>MailMarshal</FONT> - </STRONG>For more information
please visit<STRONG> </STRONG><A
href="http://www.marshalsoftware.com"><STRONG>www.marshalsoftware.com</STRONG></A><STRONG>
</STRONG>
<HR>
</BLOCKQUOTE><CODE><FONT SIZE=3><BR>
<BR>
**********************************************************************<BR>This message (including any attachments) is confidential and may be <BR> legally privileged. If you are not the intended recipient, you should <BR> not disclose, copy or use any part of it - please delete all copies <BR> immediately and notify the Hays Group Email Helpdesk at<BR> email.helpdesk_at_hays.com<BR>
**********************************************************************<BR>
------_=_NextPart_001_01C2DBF5.0AC6B3E0--
-- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Lord, David - CSG INET: david.lord_at_hays.com Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).Received on Mon Feb 24 2003 - 05:13:43 CST