Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2008
    Posts
    3

    Unanswered: 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

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    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!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Jun 2008
    Posts
    3
    I am executing the statement before fetching the cursor

  4. #4
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    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!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  5. #5
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    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?

  6. #6
    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;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •