ORA-01002: fetch out of sequence

15 pts.
Tags:
ORA-01002
Oracle
We have a procedure in production working but in testing, both are failing:
create or replace PROCEDURE Crown_spu (p_nbrec IN NUMBER, p_recordset OUT Crown_Types.Crown_cursor) AS w_batchid VARCHAR2(20);
w_nbrec NUMBER := 0;
w_seq NUMBER := 0;
CURSOR c_feedback IS SELECT Eventid_0, Eventkey_0, Eventtype_0, Batchid_0, Eventsta_0, Eventprty_0,
Polldat_0, Credat_0 From YEVENTS  WHERE  eventsta_0 = 0 and eventtype_0='SIH'  FOR UPDATE OF eventsta_0;
w_record yevents%ROWTYPE;
BEGIN w_batchid := to_char(sysdate,'YYYYMMDDHH24MISS');
OPEN c_feedback;
LOOP FETCH c_feedback INTO w_record;
EXIT WHEN c_feedback%NOTFOUND;
UPDATE yevents SET eventsta_0=2, batchid_0=w_batchid, polldat_0=sysdate WHERE CURRENT OF c_feedback;
w_nbrec := w_nbrec + 1;
IF w_nbrec >= p_nbrec THEN EXIT;
END IF;
End LOOP;
OPEN p_recordset FOR SELECT batchid_0, eventid_0, eventkey_0, eventtype_0 FROM YEVENTS WHERE  batchid_0=w_batchid;
END Crown_spu;
Error: ORA-01002: Fetch out of sequence
0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 4  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • carlosdl
    What is the line of code where the error is raised?
    Are you sure it is raised in this procedure?

    You do have something incorrect there because you never close the c_feedback cursor, but I wouldn't expect that to cause an ORA-01002 error.

    You only posted one procedure, what do you mean by "both are failing"?
    85,055 pointsBadges:
    report
  • MikeBerry

    I don't know what line creates the issue

    doesn't have close in the production environment but it works

    sorry we have two testing environments

    15 pointsBadges:
    report
  • carlosdl
    Don't you get the line and column position in the error message?

    It can help if you post the complete error message.
    85,055 pointsBadges:
    report
  • carlosdl
    And as I said, I don't think the problem is caused by not closing the cursor, but you have to fix that anyway (it will eventually cause you other problems if you don't).
    85,055 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: