1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| create directory fichiers_in as 'd:\fichiers\in' ;
grant read on directory fichiers_in to public ;
create directory fichiers_out as 'd:\fichiers\out' ;
grant read, write on directory fichiers_out to public ;
SQL> declare
2
3 lc$fic_in varchar2(128) := 'emp.txt' ;
4 lc$dir_in varchar(30) := 'FICHIERS_IN';
5
6 lf$ficin utl_file.file_type ;
7
8 lc$ligne varchar2(32767) ;
9
10 lc$msg varchar2(256) ;
11 le$fin exception ;
12 begin
13
14 begin
15 lf$ficin := utl_file.fopen( lc$dir_in, lc$fic_in, 'r', 32764 ) ;
16 exception
17 when others then
18 lc$msg := sqlerrm || ' [' || lc$dir_in || '] -> ' || lc$fic_in;
19 raise le$fin ;
20 end ;
21 begin
22 loop
23 utl_file.get_line( lf$ficin, lc$ligne ) ;
24 end loop ;
25 exception
26 when no_data_found then
27 utl_file.fclose( lf$ficin ) ;
28 end ;
29
30 exception
31 when le$fin then
32 utl_file.fclose_all ;
33 raise_application_error( -20100, lc$msg ) ;
34 end ;
35 /
Procédure PL/SQL terminée avec succès.
SQL> |
Partager