File Input/Output (I/O) (UTL_FILE)

- It is a DB Package
- Used for
- to create flat file
- to load data into Oracle DB from flat file
- It do validation also
FOPEN
FCLOSE
GET_LINE
NEW_LINE
PUT
Datatype = File_type

create or replace procedure proc_a as
vfile_id utl_file.file_type;
vstring varchar2(100);
vcode varchar2(10);
vname varchar2(10);
begin
vfile_id := utl_file.fopen('C:\', 'flat.txt','W') ;
loop
utl_file.get_line (vfile_id,vstring);
vcode := substr(vstring,1,2) ;
vname := substr(vstring,1,2) ;
insert into person (code,name) values (vcode,vname) ;
commit ;
end loop ;
exception
when no_data_found then
utl_file.fclose(vfile_id) ;
end ;

create or replace procedure proc_a as
vfile_id utl_file.file_type;
vstring varchar2(100);
vcode varchar2(10);
vname varchar2(10);
begin
vfile_id := utl_file.fopen('C:\', 'flat.txt','W') ;
loop
utl_file.get_line (vfile_id,vstring);
vcode := substr(vstring,1,2) ;
vname := substr(vstring,1,2) ;
insert into person (code,name) values (vcode,vname) ;
commit ;
end loop ;
exception
when no_data_found then
utl_file.fclose(vfile_id) ;
end ;