declare
ENAME VARCHAR2(10);
JOB VARCHAR2(10);
MGR VARCHAR2(4);
HIREDATE varchar2(11);
SAL VARCHAR2(11);
COMM VARCHAR2(9);
DEPTNO number(2);
EMPNO NUMBER(4);
namesfile UTL_FILE.FILE_TYPE;
begin
namesfile :=UTL_FILE.FOPEN('DIPRJDIR','empdata.txt','R');
LOOP
EMPNO:=0;
ENAME :=0;
JOB:=0;
MGR:=0;
HIREDATE:=0;
SAL:=0;
COMM :=0;
DEPTNO:=0;
UTL_FILE.GET_LINE(namesfile,EMPNO,4);
dbms_output.put_line('EMPNO :' || EMPNO);
UTL_FILE.GET_LINE(namesfile,ENAME,10);
dbms_output.put_line('ENAME :' || ENAME);
UTL_FILE.GET_LINE(namesfile,JOB,9);
dbms_output.put_line('JOB :' || JOB);
UTL_FILE.GET_LINE(namesfile,MGR,4);
dbms_output.put_line('MGR :' || MGR);
UTL_FILE.GET_LINE(namesfile,HIREDATE,11);
dbms_output.put_line('HIREDATE :' || HIREDATE);
UTL_FILE.GET_LINE(namesfile,SAL,11);
dbms_output.put_line('SAL :' || SAL);
UTL_FILE.GET_LINE(namesfile,COMM,9);
dbms_output.put_line('COMM :' || COMM);
UTL_FILE.GET_LINE(namesfile,DEPTNO,2);
dbms_output.put_line('DEPTNO :' || DEPTNO);
END LOOP;
END;
In the loop it display data only one time after than it give error
SQL> /
EMPNO :7839
ENAME :KING
JOB :PRESIDENT
MGR :0000
HIREDATE :17-nov-1981
SAL : 005000.00
COMM :000000.00
DEPTNO :10
declare
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at line 22
我已经编写了程序,但它没有给我正确的输出。它只能显示一次数据。你能解释一下为什么它只显示一次数据,然后它给出一个错误。