Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Cursor returns only last record

M1k3GOct 17 2010 — edited Nov 18 2010
Hi. I have created an explicit cursor loop, but this is returning only the last value. The cursor itself is defined as a function. The function is called as a line in a procedure, which is inserting into a table. I am using the results from the cursor to insert lines in a table. All lines are correctly inserted, except for the values returned from the cursor, which is always the last value found from the loop. I noticed online that the command NEXT RECORD should resolve this issue, but PLSQL won't recognize this. The cursor loop looks like this:
BEGIN
  
    OPEN Quant_Requested;
    LOOP
      FETCH Quant_Requested
        INTO v_rob_qty, v_req_qty, v_app_qty;
      EXIT WHEN Quant_Requested%NOTFOUND;
      NEXT RECORD;  --PLS-00103 Encountered the symbol 'RECORD'

    END LOOP;
    CLOSE Quant_Requested;
    FIRST RECORD;
  END;
  RETURN v_req_qty;
END;
The question now is, how can I get oracle to process each and every line, rather than just the last result found?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 16 2010
Added on Oct 17 2010
16 comments
1,522 views