Hi ,
i have created a file 'writefile' using below and it is created successfully.
=================================
declare
ltype utl_file.file_type;
ldir varchar2(100) := 'DATA_PUMP_DIR';
lfile varchar2(100) := 'writefile.sql';
s varchar2(10) := ',';
begin
ltype := utl_file.fopen(ldir,lfile,'w');
for i in (select * from emp)
loop
utl_file.putf(ltype,i.empid||s||i.sal);
UTL_FILE.NEW_LINE(ltype);
end loop;
utl_file.fclose(ltype);
end;
==================================================
out put <writefile.sql>
184,4200
185,4100
186,3400
....
i have created a new table tmp with empid and first_name columns, could you please let me know how could i read this file and load the data into new table tmp ...
i tried using this but its not working..
=================
declare
f UTL_FILE.FILE_TYPE;
ldir varchar2(100) := 'DATA_PUMP_DIR';
lfile varchar2(100) := 'writefile.sql';
s VARCHAR2(200);
BEGIN
f := UTL_FILE.FOPEN(ldir,lfile,'R');
IF UTL_FILE.IS_OPEN(f) THEN
LOOP
BEGIN
UTL_FILE.GET_LINE(f,lfile);
IF lfile IS NULL THEN
EXIT;
END IF;
INSERT INTO tmp
(empid, first_name)
VALUES
( );
END;
END LOOP;
COMMIT;
END IF;
END;
===========================================