2. Beispiel - Verarbeitung in einer Loop
/** Beispiel aus Example 1, diesmal Verarbeitung der Datensätze
* in einer LOOP.
*/
CREATE OR REPLACE FUNCTION Test RETURN NUMBER IS
tmpVar NUMBER;
CURSOR curTmp IS
select 2 * 8 from dual;
BEGIN
tmpVar := 0;
OPEN curTmp;
LOOP
FETCH curTmp into tmpVar;
EXIT WHEN curTmp%NOTFOUND;
END LOOP;
RETURN tmpVar;
CLOSE curTmp;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
WHEN OTHERS THEN
-- Consider logging the error and then re-raise
RAISE;
END test;
/
OPEN curTmp;
LOOP
FETCH curTmp into tmpVar;
EXIT WHEN curTmp%NOTFOUND;
END LOOP;
RETURN tmpVar;
CLOSE curTmp;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
WHEN OTHERS THEN
-- Consider logging the error and then re-raise
RAISE;
END test;
/
Keine Kommentare:
Kommentar veröffentlichen