3. Beispiel - For-Cursor-Loop
* Diesmal mit FOR-CURSOR-LOOP ...
*/
CREATE OR REPLACE FUNCTION Test RETURN NUMBER IS
tmpVar NUMBER;
CURSOR curTmp IS
select * from unit;
BEGIN
tmpVar := 0;
FOR recVar IN curTmp LOOP
tmpVar := recVar.unit_id;
END LOOP;
RETURN tmpVar;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
WHEN OTHERS THEN
-- Consider logging the error and then re-raise
RAISE;
END test;
/
FOR recVar IN curTmp LOOP
tmpVar := recVar.unit_id;
END LOOP;
RETURN tmpVar;
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