Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Using Pl/SQL temp table
In article <3a72fcfb.34527777_at_news.iinet.net.au>, Arthur <mechhunter_at_rocketmail.com> writes
Your use of the X is a little inconsistent:
> 7 CURSOR emp_cur IS
> 8 SELECT job, deptno
> 9 FROM emp
> 10 ORDER BY deptno;
> 11
> 12 x NUMBER := 0;
Starts at zero, but loop assumes that it starts at 1
> 22
> 23 FOR k IN 1..x LOOP
> 24 IF v_char = dept_job(x) THEN EXIT;
> 25 ELSIF
> 26 (v_char != dept_job(x) and k >= x-1) THEN
> 27 RAISE_APPLICATION_ERROR(-20500, 'Not a valid
>job for this department.');
> 28 END IF;
> 29 END LOOP;
> 30 END chk_dept_job;
> 31 --END PROCEDURE
> 32
> 33 BEGIN
> 34 FOR emp_rec IN emp_cur LOOP
> 35 dept_job(x) := to_char(emp_rec.deptno)||(emp_rec.job);
> 36 x:= x+1;
> 37 END LOOP;
> 38
> 39* END chk_pack;
Maybe you have only one entry in the emp table? If so, it's value would be stored in dept_job(0), but the loop would look at dept_job(1) which does not exist?
Andy
-- Andy Hardy. PGP ID: 0xA62A4849 ===============================================================Received on Sat Jan 27 2001 - 13:53:20 CST