Home » SQL & PL/SQL » SQL & PL/SQL » Cursor in a sql statement
Cursor in a sql statement [message #211962] Wed, 03 January 2007 04:42 Go to next message
theo06
Messages: 29
Registered: February 2006
Junior Member
Hi,

I have the following Statement that can be executed without any problems. But I wonder why it works...
begin

declare TYPE refcur IS REF CURSOR;

cursor cur is
	   select RECHNUNG_ID
	     from rechnung
		where trunc(RECHNUNG_DATUM) >= to_date('22.12.2006','dd.mm.yyyy');
	 				
rechnung cur%ROWTYPE;
begin
	 open cur;		
loop
    	 fetch cur into rechnung;
		 exit when cur%NOTFOUND;
		 
storno(rechnung.rechnung_id );
end loop;
close cur;
end;
end;

Can anyone explain the row 'declare TYPE refcur IS REF CURSOR;' to me?
I don't understand why the statement with this row works fine but without that row does not.
In my eyes that line declares the variable refcur without any special type (...dirty). But refcur is not used anymore in that Statement. So it makes no sense to me why that line has to be there...

Thank you in advance for your help!
Re: Cursor in a sql statement [message #211963 is a reply to message #211962] Wed, 03 January 2007 04:46 Go to previous messageGo to next message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
theo06
... but without that row does not.

What does it mean?
Re: Cursor in a sql statement [message #211969 is a reply to message #211963] Wed, 03 January 2007 05:06 Go to previous message
theo06
Messages: 29
Registered: February 2006
Junior Member
I will answer my stupid question by my self:

The important point is the keyword 'declare'.
The rest of that line 'TYPE refcur IS REF CURSOR;' is of course for that statement not important! Wink
Sorry!

Previous Topic: Need help in extracting a string from text.......
Next Topic: Increase Pipeline Performance
Goto Forum:
  


Current Time: Fri Dec 09 11:47:12 CST 2016

Total time taken to generate the page: 0.26075 seconds