This is a script that I had that deals with a table containing
both a department name and a manger name: tablecomp.sql.
SET SERVEROUTPUT ON DECLARE v_dept_name_in varchar2(20) := '&input_dept_name'; TYPE dept_rec is RECORD (dept_name varchar2(20), dept_mang varchar2(20)); a_dept_rec dept_rec; TYPE dept_rec_table is TABLE of a_dept_rec%TYPE INDEX BY BINARY_INTEGER; a_dept_rec_table dept_rec_table; v_mang varchar2(20); v_dept_rec a_dept_rec%TYPE; BEGIN a_dept_rec.dept_name := 'clothes'; a_dept_rec.dept_mang := 'Fox'; a_dept_rec_table(1) := a_dept_rec; a_dept_rec.dept_name := 'toys'; a_dept_rec.dept_mang := 'Brown'; a_dept_rec_table(2) := a_dept_rec; v_dept_rec := a_dept_rec_table(1); dbms_output.put_line(v_dept_name_in); dbms_output.put_line(v_dept_rec.dept_name); if v_dept_name_in = v_dept_rec.dept_name then v_mang := v_dept_rec.dept_mang; dbms_output.put_line(v_mang); end if; v_dept_rec := a_dept_rec_table(2); dbms_output.put_line(v_dept_rec.dept_name); if v_dept_name_in = v_dept_rec.dept_name then v_mang := v_dept_rec.dept_mang; dbms_output.put_line(v_mang); end if; END; /