I had written program which copy data into txt file program is given below
declare
empsfile utl_file.file_type;
cursor empscur is
select * from newemp;
begin
empsfile := utl_file.fopen('DIPRJDIR','EMPS.TXT','W');
for rec in empscur
loop
utl_file.put_line(empsfile,rec.EMPNO||rec.ENAME||rec.JOB||rec.MGR||rec.HIREDATE||rec.SAL||rec.COMM||rec.DEPTNO);
end loop;
UTL_FILE.FCLOSE(empsfile );
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE( 'ERROR -->' || SQLERRM);
END;
/
output of the above progarm is
7839KING PRESIDENT017-NOV-815000010
7698BLAKE MANAGER 783901-MAY-812850.5.530
7782CLARK MANAGER 783909-JUN-812450010
7566JONES MANAGER 783902-APR-812975020
7654MARTIN SALESMAN 769828-SEP-811250140030
7499ALLEN SALESMAN 769820-FEB-81160030030
7844TURNER SALESMAN 769808-SEP-811500030
7900JAMES CLERK 769803-DEC-81950030
7521WARD SALESMAN 769822-FEB-81125050030
7902FORD ANALYST 756603-DEC-813000020
7369SMITH CLERK 790217-DEC-80800020
7788SCOTT ANALYST 756609-DEC-823000020
7876ADAMS CLERK 778812-JAN-831100020
7934MILLER CLERK 778223-JAN-821300010
Now my problem is I want display space according to data type of above field for example suppose ENAME VARCHAR2(10) than if name in data is 6 field than i have to display 4 blank space please help me in this .
Can LPAD function help you?