PROCEDURE CON CURSOR ORACLE
--PROCEDURE CON CURSOR
CREATE OR REPLACE PROCEDURE P_BUSCAR (COD NUMBER) IS
BEGIN
DECLARE CURSOR C_LISTADO IS
SELECT * FROM EMPLOYEES WHERE EMPLOYEE_ID=COD;
S EMPLOYEES%ROWTYPE;
BEGIN
OPEN C_LISTADO;
LOOP
FETCH C_LISTADO INTO S;
EXIT WHEN C_LISTADO%NOTFOUND;
dbms_output.put_line('ID: ' || S.EMPLOYEE_ID);
dbms_output.put_line('NOMBRES: ' || S.FIRST_NAME);
dbms_output.put_line('APELLIDOS: ' || S.LAST_NAME);
END LOOP;
CLOSE C_LISTADO;
END;
END;
--PROBANDO PROCEDURE
BEGIN
P_BUSCAR('100');
END;
CREATE OR REPLACE PROCEDURE P_BUSCAR (COD NUMBER) IS
BEGIN
DECLARE CURSOR C_LISTADO IS
SELECT * FROM EMPLOYEES WHERE EMPLOYEE_ID=COD;
S EMPLOYEES%ROWTYPE;
BEGIN
OPEN C_LISTADO;
LOOP
FETCH C_LISTADO INTO S;
EXIT WHEN C_LISTADO%NOTFOUND;
dbms_output.put_line('ID: ' || S.EMPLOYEE_ID);
dbms_output.put_line('NOMBRES: ' || S.FIRST_NAME);
dbms_output.put_line('APELLIDOS: ' || S.LAST_NAME);
END LOOP;
CLOSE C_LISTADO;
END;
END;
--PROBANDO PROCEDURE
BEGIN
P_BUSCAR('100');
END;
Comentarios