Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > Oracle
| Search | Today's Posts | Mark Forums Read
Oracle General Oracle database discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Oracle section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 31st, 2007, 06:05 AM
Authorized User
 
Join Date: Jan 2007
Location: , , .
Posts: 46
Thanks: 2
Thanked 1 Time in 1 Post
Default

How do we come to know that we have reached the end of record in a cursor for loop.
For example, i have this PL/SQL block:

DECLARE
   CURSOR c1 IS
      SELECT sal FROM emp;
   SALARY_TOTAL NUMBER:=0;
BEGIN
   FOR emp_rec IN c1 LOOP
      salary_total := salary_total + emp_rec.sal;
      ---dbms_output.put_line(salary_total);
   END LOOP;
END;

And i want to output the total salary when the FOR LOOP reaches the end of the record,how am i going to determine that we have reached the end of the record.


MAXOOD!

Life is an endless journey towards perfection
 
Old July 24th, 2007, 06:47 AM
Authorized User
 
Join Date: Sep 2004
Location: Edegem, Antwerpen, Belgium.
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

When using cursors, you can use the following code:
WHEN cursor_name%NOTFOUND ...

I used this to exit a loop at the end of the cursor in the following script: http://geertverhoeven.blogspot.com/2...rns-table.html
Greetz,

Geert

http://geertverhoeven.blogspot.com
 
Old April 9th, 2009, 04:42 PM
Authorized User
 
Join Date: Mar 2007
Location: New Delhi, Delhi, India.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Smile

hi,

u didnt mention whether u r getting any error msg or result is not displayed. ur code looks fine, if output is not returned then check ur server output by...
Code:
show serveroutput
if its off then turn it on by..
Code:
set serveroutput on
__________________
Akhil




Similar Threads
Thread Thread Starter Forum Replies Last Post
Have a problem in For-each loop LeoMathew XSLT 2 July 16th, 2008 05:20 AM
cursor disappearance problem nasirmunir Javascript How-To 7 July 3rd, 2008 03:49 PM
Cursor Blink Problem in FireFox aliirfan84 ASP.NET 1.0 and 1.1 Professional 1 June 11th, 2008 08:46 AM
Magnetic Cursor - Target Area Cursor? gcarcass .NET Framework 2.0 1 May 5th, 2008 07:20 AM
loop problem smilesmita Pro PHP 1 November 2nd, 2007 02:15 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.