試してみてください:
begin for emp_complex_rec in (select e.fname, d.dlocation from employee e INNER JOIN dept_location d ON (e.dno = d.dnumber)) loop dbms_output.put_line('The employee id is: ' || emp_complex_rec.rname || ' and the employee''s location is ' || emp_complex_rec.rlocation); end loop; end;
プレ>元のコードの問題は、
emp_complex_rec
の定義が 型がemp_complex_rec
の定義と衝突していたため カーソルループ変数として。明示的なカーソル定義も必要ありません-IMOはSELECT
を入れますFOR
で ループはより簡単で明確です。共有して楽しんでください。