Re[2]: For i (Select..)

2001-10-02 Thread dgoulet

You can do all three, but if you do not declare it you can't use the 'for update
of' clause. Of course the 'for i in ()loop' does replace a lot of lines of code.

Dick Goulet

Reply Separator
Author: Steve Smith [EMAIL PROTECTED]
Date:   10/1/2001 7:50 PM

You can also use the for loop - end loop with explicit cursors..  You don't
have to define the cursor in the loop itself..  That is my preferred method
(defining the cursor in the declare section and referencing it in the for
loop)..  There really isn't any more work defining the cursor up front and
then using the for loop as there is using the for loop and defining the
cursor in the loop..

Steve

- Original Message -
To: Multiple recipients of list ORACLE-L [EMAIL PROTECTED]
Sent: Monday, October 01, 2001 6:01 PM


 If you only use a cursor in this manner, the only place that the cursor
can
 be used is in the particular For Loop in which it is defined - it can't be
 shared by other procedures or functions.

 If you design and create packaged public cursors, they can be reused from
 other stored procedures and/or client side programs.

 Code reuse is just one advantage.  When table structures change - as they
 invariably do - you have only a few cursors to change, instead of a
 bazillion Cursor For Loops.  Also, you can more easily tune a few public
 cursors.

 I'd also recommend passing in Table%RowType arguments to your public
cursors
 and specifying that they return Table%RowType records.  That further
 isolates your code from table changes.

 Jack

 
 Jack C. Applewhite
 Database Administrator/Developer
 OCP Oracle8 DBA
 iNetProfit, Inc.
 Austin, Texas
 www.iNetProfit.com
 [EMAIL PROTECTED]
 (512)327-9068


 -Original Message-
 Zsolt
 Sent: Monday, October 01, 2001 6:15 PM
 To: Multiple recipients of list ORACLE-L


 Hi,

 If this code is a cursor then why doesn't everybody use it this way?

 For me it seems a lot simplier and easier than declaring a cursor in a
 normal way.

 At 14:50 2001.10.01. -0800, you wrote:
 the code IS a cursor
 
 
 --- Csillag Zsolt [EMAIL PROTECTED] wrote:
  
  
   Hi,
  
  
   I've read in Tom Kyte's book the following technique:
  
  
  For i in (Select statement ) Loop
  
 Process records here
  
  End Loop ;
  
 I have tried it and it works great.
  
   The question is that what is the difference betwen a cursor and the
   code above?
   Which is more efficient?
  
  

 Zsolt Csillag
 Hungary

 --
 Please see the official ORACLE-L FAQ: http://www.orafaq.com
 --
 Author: Jack C. Applewhite
   INET: [EMAIL PROTECTED]

 Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
 San Diego, California-- Public Internet access / Mailing Lists
 
 To REMOVE yourself from this mailing list, send an E-Mail message
 to: [EMAIL PROTECTED] (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).


-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Steve Smith
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (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).
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: 
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (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).



Re[2]: For i (Select..)

2001-10-02 Thread Csillag Zsolt


Thank you very much.
Your answers explained everything about explicit and implicit cursors.

At 07:00 2001.10.02. -0800, you wrote:
You can do all three, but if you do not declare it you can't use the 'for 
update
of' clause. Of course the 'for i in ()loop' does replace a lot of lines of 
code.

Dick Goulet

Reply Separator
Author: Steve Smith [EMAIL PROTECTED]
Date:   10/1/2001 7:50 PM

You can also use the for loop - end loop with explicit cursors..  You don't
have to define the cursor in the loop itself..  That is my preferred method
(defining the cursor in the declare section and referencing it in the for
loop)..  There really isn't any more work defining the cursor up front and
then using the for loop as there is using the for loop and defining the
cursor in the loop..

Steve

- Original Message -
To: Multiple recipients of list ORACLE-L [EMAIL PROTECTED]
Sent: Monday, October 01, 2001 6:01 PM


  If you only use a cursor in this manner, the only place that the cursor
can
  be used is in the particular For Loop in which it is defined - it can't be
  shared by other procedures or functions.
 
  If you design and create packaged public cursors, they can be reused from
  other stored procedures and/or client side programs.
 
  Code reuse is just one advantage.  When table structures change - as they
  invariably do - you have only a few cursors to change, instead of a
  bazillion Cursor For Loops.  Also, you can more easily tune a few public
  cursors.
 
  I'd also recommend passing in Table%RowType arguments to your public
cursors
  and specifying that they return Table%RowType records.  That further
  isolates your code from table changes.
 
  Jack
 

Zsolt Csillag
Hungary

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Csillag Zsolt
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (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).