Bonjour, voici comment j'ai fait sous ORACLE :(et ça marche très bien)
SQL>CREATE OR REPLACE DIRECTORY MON_REP as 'chemin_de_votre_rep';
-- 'c:\test\' sous win ou '/home/oracle_user/test/' sous linux
Directory created.
SQL> GRANT READ, WRITE ON DIRECTORY MON_REP TO PUBLIC ;
Grant succeeded.
Puis dans votre bloc (anonyme, procédure, fonction) PL/SQL :
DECLARE
f_file_id UTL_FILE.FILE_TYPE;
v_file_location VARCHAR2(256) := 'MON_REP';
v_line VARCHAR2(4000);
BEGIN
dbms_output.put_line(v_file_location);
f_file_id := UTL_FILE.FOPEN(v_file_location,'first_file.txt','w');
UTL_FILE.PUT_LINE(f_file_id,'Hello Wolrd -- Comment ca marche ?!');
UTL_FILE.FCLOSE (f_file_id);
f_file_id := UTL_FILE.FOPEN(v_file_location,'first_file.txt','r');
UTL_FILE.GET_LINE(f_file_id,v_line);
DBMS_OUTPUT.PUT_LINE(v_line);
UTL_FILE.FCLOSE (f_file_id);
EXCEPTION
WHEN OTHERS
THEN
dbms_output.put_line(SQLERRM);
UTL_FILE.FCLOSE_ALL;
END;
/