I'd like to output STATEMENT_NUMBER
for each record where ID
is between 10 and 40
I tried writing the below :-
DECLARE
tempid NUMBER := 10;
tempresult VARCHAR2(20);
BEGIN
LOOP
SELECT
statement_number
INTO
tempresult
FROM
tblstatementsnew
WHERE
id = tempid;
dbms_output.put_line(tempresult);
tempid := tempid + 1;
EXIT WHEN tempid = 40;
END LOOP;
END;
..but I get the error :-
*Cause: No data was found from the objects. *Action: There was no data from the objects which may be due to end of fetch.
I appreciate there are more simple ways of getting these results, but I'm attempting to learn more about how loops work.