Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Another question on Code

Another question on Code

From: Arthur <mechhunter_at_rocketmail.com>
Date: Sat, 27 Jan 2001 15:56:50 GMT
Message-ID: <3a72eefa.30942333@news.iinet.net.au>

This work, but see on the line that reads FOR emp_rec IN job_cur LOOP...
What I don't understand is, why was there no need to declare emp_rec ????

SET SERVEROUTPUT ON
DECLARE
TYPE job_dept_table IS TABLE OF VARCHAR2(60) INDEX BY BINARY_INTEGER;

job_dept 	job_dept_table;
v_both		VARCHAR2(60);
x		NUMBER:=0;
v_count		NUMBER;

CURSOR job_cur IS
	SELECT DISTINCT job, deptno
	FROM emp
	ORDER BY deptno;

BEGIN
	FOR emp_rec IN job_cur LOOP
	job_dept(x) := to_char(emp_rec.deptno)||(emp_rec.job);
	x:= x+1;
	END LOOP;
	
	DBMS_OUTPUT.put_line(x);
	x:=x-1;
	FOR i IN 1..x LOOP
	DBMS_OUTPUT.PUT_LINE(job_dept(i));
	END LOOP;	

END;
/

Another question, when you have a PL/SQL table.. is there no way you can use SELECT using the PL/SQL table within the same code where the table was create ?

Many thanks in advance.

Arthur Received on Sat Jan 27 2001 - 09:56:50 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US