Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > Oracle
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #11 (permalink)  
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
  #12 (permalink)  
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
  #13 (permalink)  
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
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 08:16 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.