Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > Oracle > Problems with fetching cursors

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-26-08, 19:08
johnwcv johnwcv is offline
Registered User
 
Join Date: Jun 2008
Posts: 3
Problems with fetching cursors

HI.

I have a problem with fetching cursor. The pl/sql is

.....
LOOP
FETCH entidades into entidad;
EXIT WHEN entidades%NOTFOUND;
END LOOP;
CLOSE entidades;
.....

When entidades has 1 or more records, it works.
But when entidades has no records, I get the next error:
ORA-24338: statement handle not executed


What can i do?

Thanks in advance
Reply With Quote
  #2 (permalink)  
Old 06-26-08, 19:12
anacedent anacedent is offline
Registered User
 
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 3,564
Code:
24338, 00000, "statement handle not executed" // *Cause: A fetch or describe was attempted before executing a // statement handle. // *Action: Execute a statement and then fetch or describe the data.
__________________
You can lead some folks to knowledge, but you can not make them think.
The average person thinks he's above average!
Reply With Quote
  #3 (permalink)  
Old 06-26-08, 19:18
johnwcv johnwcv is offline
Registered User
 
Join Date: Jun 2008
Posts: 3
I am executing the statement before fetching the cursor
Reply With Quote
  #4 (permalink)  
Old 06-26-08, 19:54
anacedent anacedent is offline
Registered User
 
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 3,564
Do you honestly think Oracle is mis-reporting reality?
Do you think the problem is a bug in Oracle & not in your code?
__________________
You can lead some folks to knowledge, but you can not make them think.
The average person thinks he's above average!
Reply With Quote
  #5 (permalink)  
Old 06-27-08, 02:14
Littlefoot Littlefoot is offline
Lost Boy
 
Join Date: Jan 2004
Location: Croatia, Europe
Posts: 2,715
Quote:
Originally Posted by johnwcv
I am executing the statement before fetching the cursor
Which one?

Just a suggestion: why don't you use cursor FOR loop? It is easier to maintain as you don't have to declare cursor variable, open a cursor, worry when to exit a loop and close a cursor.

Here's an example of code you currently use:
Code:
declare cursor c1 is select dname from dept; c1_r c1%rowtype; begin open c1; loop fetch c1 into c1_r; exit when c1%notfound; dbms_output.put_line(c1_r.dname); end loop; close c1; end;
Here's the same code, but slightly rewritten:
Code:
begin for c1_r in (select dname from dept) loop dbms_output.put_line(c1_r.dname); end loop; end;
Which one do you prefer?
Reply With Quote
  #6 (permalink)  
Old 06-27-08, 09:45
johnwcv johnwcv is offline
Registered User
 
Join Date: Jun 2008
Posts: 3
anacedent, I know there is a bug in my code.

Littlefoot, the problem is that entidades (the cursor), is an out parameter of other procedure:

int_packagename_pkg.int_otherprocedurename_spr(pin _id, pin_login, entidades);

LOOP
FETCH entidades INTO entidad;
EXIT WHEN entidades%NOTFOUND;
END LOOP;
CLOSE entidades;
Reply With Quote
Reply


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

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