Home » SQL & PL/SQL » SQL & PL/SQL » getting error in cimple cursor
getting error in cimple cursor [message #563739] Thu, 16 August 2012 12:59 Go to next message
mickey0204
Messages: 10
Registered: May 2012
Junior Member
Connected to Personal Oracle Database 10g Release 10.2.0.3.0
Connected as scott

SQL>
SQL> set server output on
Cannot SET SERVER
SQL> set verify off
SQL> declare
2 naam varchar2(99);
3 jobe varchar2(99);
4 cursor jbd is select ename from emp where job='CLERK';
5
6 Begin
7 open jbd;
8 loop
9 fetch jbd into naam;
10 exit when jbd%notfound;
11 end loop;
12 dbms_output.put_line('Naam is ' || naam);
13
14 if jbd%rowcount=0 then
15 close jbd;
16 end if;

17 /

declare
naam varchar2(99);
jobe varchar2(99);
cursor jbd is select ename from emp where job='CLERK';

Begin
open jbd;
loop
fetch jbd into naam;
exit when jbd%notfound;
end loop;
dbms_output.put_line('Naam is ' || naam);

if jbd%rowcount=0 then
close jbd;
end if;

ORA-06550: line 19, column 0:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:

begin case declare end exception exit for goto if loop mod
null pragma raise return select update while with
<an identifier> <a double-quoted delimited-identifier>
<a bind variable> << close current delete fetch lock insert
open rollback savepoint set sql execute commit forall merge
pipe

SQL>
Re: getting error in cimple cursor [message #563740 is a reply to message #563739] Thu, 16 August 2012 13:02 Go to previous messageGo to next message
BlackSwan
Messages: 22926
Registered: January 2009
Senior Member
Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/


every BEGIN must have a corresponding END & posted code does not conform.
Re: getting error in cimple cursor [message #563741 is a reply to message #563740] Thu, 16 August 2012 13:03 Go to previous messageGo to next message
mickey0204
Messages: 10
Registered: May 2012
Junior Member
Such a silly mistake thanks BlackSwan.I am really #$@%$^##$ (stupid).Smile Thanks
Re: getting error in cimple cursor [message #563745 is a reply to message #563741] Thu, 16 August 2012 13:50 Go to previous messageGo to next message
Michel Cadot
Messages: 59499
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
I am really #$@%$^##$ (stupid).


Is this really to your lack of following the forum guide and format your code? I could not say it better... Smile

Regards
Michel
Re: getting error in cimple cursor [message #563746 is a reply to message #563741] Thu, 16 August 2012 13:53 Go to previous message
Solomon Yakobson
Messages: 2050
Registered: January 2010
Senior Member
mickey0204 wrote on Thu, 16 August 2012 14:03
Such a silly mistake


There is more. Your code will not close cursor if it fetches no rows. Change if jbd%rowcount=0 to if jbd%ISOPEN.

SY.

[Updated on: Thu, 16 August 2012 13:53]

Report message to a moderator

Previous Topic: A Join with more than on table
Next Topic: PL/SQL question
Goto Forum:
  


Current Time: Thu Oct 30 23:14:36 CDT 2014

Total time taken to generate the page: 0.10112 seconds