Returning a Record from a Function
DECLARE
TYPE EMPRECTYP IS RECORD(EMP_ID NUMBER(6),
SALARY NUMBER(8,2));
CURSOR DESC_SALARY RETURN EMPRECTYP IS
SELECT EMPLOYEE_ID,
SALARY
FROM EMPLOYEES
ORDER BY SALARY DESC;
EMP_REC EMPRECTYP;
FUNCTION NTH_HIGHEST_SALARY
(N INTEGER)
RETURN EMPRECTYP
IS
BEGIN
OPEN DESC_SALARY;
FOR I IN 1.. N LOOP
FETCH DESC_SALARY INTO EMP_REC;
END LOOP;
CLOSE DESC_SALARY;
RETURN EMP_REC;
END NTH_HIGHEST_SALARY;
BEGIN
NULL;
END;
/
0 comments:
Post a Comment