Example:-
DECLARE
TYPE EMPRECTYPE IS RECORD (LAST_NAME EMPLOYEES.LAST_NAME%TYPE,
SALARY EMPLOYEES.SALARY%TYPE);
EMPREC EMPRECTYPE;
CURSOR EMPCUR IS SELECT LAST_NAME,SALARY FROM EMPLOYEES;
BEGIN
IF NOT EMPCUR%ISOPEN THEN
OPEN EMPCUR;
END IF;
LOOP
FETCH EMPCUR INTO EMPREC;
DBMS_OUTPUT.PUT_LINE(EMPREC.LAST_NAME||' GETS '||EMPREC.SALARY);
EXIT WHEN EMPCUR%NOTFOUND;
END LOOP;
CLOSE EMPCUR;
END;
DECLARE
TYPE EMPRECTYPE IS RECORD (LAST_NAME EMPLOYEES.LAST_NAME%TYPE,
SALARY EMPLOYEES.SALARY%TYPE);
EMPREC EMPRECTYPE;
CURSOR EMPCUR IS SELECT LAST_NAME,SALARY FROM EMPLOYEES;
BEGIN
IF NOT EMPCUR%ISOPEN THEN
OPEN EMPCUR;
END IF;
LOOP
FETCH EMPCUR INTO EMPREC;
DBMS_OUTPUT.PUT_LINE(EMPREC.LAST_NAME||' GETS '||EMPREC.SALARY);
EXIT WHEN EMPCUR%NOTFOUND;
END LOOP;
CLOSE EMPCUR;
END;
0 comments:
Post a Comment