I'm having issues looping through my cursor
I have multiple location_name entries that i'm trying to display 5 at a time, and set it to look_item_cursor.
CURSOR look_item_cursor IS
SELECT *
FROM (SELECT DISTINCT location_name
FROM inventory_info_v i
WHERE i.item_code = lr_item.item_code) a
WHERE rownum <= (ln_page + 4)
AND rownum >= ln_page;
the original query returns the data back just fine. both ln_page and lr_item.item_code are filled by the time the cursor is called.
I attempt to retrieve each of the 5 returned location_name, one at a time, with
OPEN look_item_cursor;
BEGIN
FOR lv_location_name IN look_item_cursor LOOP
pv_message_return := pv_message_return ||
lv_location_name.location_name;
END LOOP;
END;
CLOSE look_item_cursor;
with lv_location_name being assigned as a
look_item_cursor%ROWTYPE
However I'm getting a general exception when it runs through the query, and i'm not sure why. Any help would be appreciated!
FORloop (as you are trying to do in your example) then 1. do not open a cursor explicitly (cursorFORloop does it for you); 2. do not declare cursor loop variable explicitly as you said you did withlv_location_namevariable (cursorFORloop does it for you). So you either work with a cursor explicitly (Open, fetch and close explicitly), or you use cursorFORloop, which does most of the work for you (opens the cursor, declares cursor variable, fetches and closes the cursor).