Código SQL:
Ver original
SET SERVEROUTPUT ON SET VERIFY OFF DECLARE TYPE depto_tipo_tabla IS TABLE OF departments.department_name%TYPE INDEX BY BINARY_INTEGER; depto_tabla depto_tipo_tabla; v_idx NUMBER(3); v_deptotal NUMBER(3); v_deptoid departments.department_id%TYPE; BEGIN SELECT COUNT(*) INTO v_deptotal FROM departments; SELECT MIN(department_id) INTO v_deptoid FROM departments; v_idx:=1; WHILE v_idx <= v_deptotal LOOP SELECT department_name INTO depto_tabla(v_idx) FROM departments WHERE department_id = v_deptoid; v_deptoid:=v_deptoid+10; v_idx:=v_idx+1; END LOOP; FOR i IN depto_tabla.FIRST..depto_tabla.LAST LOOP DBMS_OUTPUT.PUT_LINE(depto_tabla(i)); END LOOP; END;