Home > database >  Consult the cursor in the index table
Consult the cursor in the index table

Time:10-18

Consult everybody! Consult!
The following code in the for loop, emp_row and v_emp (emp_row. Empno) how do you explain the two? Does not define emp_row?

DECLARE
CURSOR cur_emp IS
SELECT * FROM emp; - define the cursor gain emp table data
TYPE emp_index IS TABLE OF emp % ROWTYPE INDEX BY PLS_INTEGER; - define the index table data type for the emp row structure
V_emp emp_index; - the index table variables
The BEGIN
FOR emp_row cur_emp IN LOOP - using cycle each row record
V_emp (emp_row empno) :=emp_row; - the employee number as index table subscript
END LOOP;
DBMS_OUTPUT. Put_line (' employee number: '| | v_emp (7369). Empno | |', the name: '| | v_emp (7369). Ename | |', position: '| | v_emp (7369). The job);
The END;

CodePudding user response:

It belongs to the category of the nested tables

CodePudding user response:

DECLARE
CURSOR cur_emp IS
SELECT * FROM emp; - define the cursor gain emp table data
TYPE emp_index IS TABLE OF emp % ROWTYPE INDEX BY PLS_INTEGER; - define the index table data type for the emp row structure
V_emp emp_index; - the index table variables
The BEGIN
FOR emp_row cur_emp IN LOOP - using cycle each row record
V_emp. Empno:=emo_row. Emono; -- to each assignment or fetch cur_emp into v_emp;
v_emp (emp_row empno) :=emp_row; - the employee number as index table subscript
END LOOP;
DBMS_OUTPUT. Put_line (' employee number: '| | v_emp (7369). Empno | |', the name: '| | v_emp (7369). Ename | |', position: '| | v_emp (7369). The job);
The END;
/
  • Related