set serveroutput on
declare
v_dept department%rowtype;
cursor c1
is
select * from department;
begin
dbms_output.put_line('부서번호 부서명 지역명');
dbms_output.put_line('-----------------------------');
open c1;
loop
fetch c1 into v_dept.dno, v_dept.dname, v_dept.loc;
exit when c1 %notfound;
dbms_output.put_line(v_dept.dno||' '||v_dept.dname||' '||v_dept.loc);
end loop;
close c1;
end;
명령의 2 행에서 시작하는 중 오류 발생 -
declare
v_dept department%rowtype;
cursor c1
is
select * from department;
begin
dbms_output.put_line('부서번호 부서명 지역명');
dbms_output.put_line('-----------------------------');
open c1;
loop
fetch c1 into v_dept.dno, v_dept.dname, v_dept.loc;
exit when c1 %notfound;
dbms_output.put_line(v_dept.dno||' '||v_dept.dname||' '||v_dept.loc);
end loop;
close c1;
end;
오류 보고 -
ORA-06550: line 2, column 12:
PLS-00201: identifier 'DEPARTMENT' must be declared
ORA-06550: line 2, column 12:
PL/SQL: Item ignored
ORA-06550: line 5, column 19:
PL/SQL: ORA-00942: table or view does not exist
ORA-06550: line 5, column 5:
PL/SQL: SQL Statement ignored
ORA-06550: line 11, column 23:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 11, column 9:
PL/SQL: SQL Statement ignored
ORA-06550: line 13, column 30:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 13, column 9:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
구글링해도 해결이 되지않아서 질문드립니다 ㅠㅠ
이런 식으로 하시면 됩니다~
SET SERVEROUTPUT ON; DECLARE CURSOR deptcur IS SELECT deptno, dname, loc FROM dept; myvar deptcur%ROWTYPE; BEGIN DBMS_OUTPUT.PUT_LINE( '부서번호 부서명 지역명' ); DBMS_OUTPUT.PUT_LINE( '-----------------------------' ); OPEN deptcur; LOOP FETCH deptcur INTO myvar; EXIT WHEN deptcur%NOTFOUND; DBMS_OUTPUT.PUT_LINE( myvar.deptno || ' ' || myvar.dname || ' ' || myvar.loc ); END LOOP; CLOSE deptcur; END;