ORA-24338: Statement handle not executed ORA-24338: Statement handle not executed oracle oracle

ORA-24338: Statement handle not executed


It seems to me that the problem is: in the first version of your stored procedure it's possible to have no resultsets to return, but in the second one you provided a resultset in the last else.

My suspition is even stronger when we understand what the ORA-24338 means by taking a look at the full error report:

Error: ORA-24338Text: statement handle not executed ---------------------------------------------------------------------------Cause: A fetch was attempted before executing a statement handle. Action: Execute a statement and then fetch the data.

A fetch was attempted, but in certain cases, there wasn´t any resultset to be fetched, until you provided it with the last else.

Your stored procedure returns a cursor by an output parameter, so you always have to open that cursor. In the first version of your code, you didn't.


I don't see any issues with the DB package PTRAIN as such (schema is TRAIN), however, the calling application (Delphi 7?) needs to know how to use the cursor. Also, try using Dynamic SQL while opening the cursors like-

OPEN p_cursorvar for    'select * from train.course where course = :p_Course' USING p_course;

And

OPEN p_cursorvar for  'select * from train.topicwhere topic = :p_topic' USING p_topic;


DevArt had a bug fix on August 2, 2007 that says "Bug with executing prepared stored procedures with REF cursor parameters fixed". I don't have any additional details other than what they provided in that statement in their bug fix list. It's possible that your version of ODAC might have that bug in it. ODAC is currently at version 8.2.8.