Essais / UTL_FILE -
utlfile_example.sql - Utilisation du package UTL_FILE
set serveroutput on CREATE OR REPLACE PROCEDURE rc_utltst IS file_handle UTL_FILE.FILE_TYPE; BEGIN file_handle := UTL_FILE.FOPEN('l:\db8\utlfiledir','file1.txt','w'); DBMS_OUTPUT.PUT_LINE('Start'); UTL_FILE.PUT_LINE(file_handle,'Bonjour chez Vous !'); UTL_FILE.PUT_LINE(file_handle,'Je ne vous berne pas, la date est ' || to_char(sysdate)); UTL_FILE.FFLUSH(file_handle); UTL_FILE.FCLOSE(file_handle); DBMS_OUTPUT.PUT_LINE('Fin !'); EXCEPTION WHEN NO_DATA_FOUND THEN DBMS_OUTPUT.PUT_LINE('No_data_found'); UTL_FILE.FCLOSE(file_handle); WHEN UTL_FILE.INVALID_PATH THEN DBMS_OUTPUT.PUT_LINE('UTL_FILE.INVALID_PATH'); UTL_FILE.FCLOSE(file_handle); WHEN UTL_FILE.READ_ERROR THEN DBMS_OUTPUT.PUT_LINE('UTL_FILE.READ_ERROR'); UTL_FILE.FCLOSE(file_handle); WHEN UTL_FILE.WRITE_ERROR THEN DBMS_OUTPUT.PUT_LINE('UTL_FILE.WRITE_ERROR'); UTL_FILE.FCLOSE(file_handle); WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('Autres erreurs'); UTL_FILE.FCLOSE(file_handle); END; / set echo on; column name format a20 wrapped column value format a20 wrapped column description format a40 wrapped select name, value, description from v$parameter where name like 'utl%' or num = 305; set serveroutput on exec rc_utltst doc /* || Exemple d'utilisation du package UTL_FILE (Le Nirvana des logs ;-)) || La procedure stockee s'appelle rc_utltst || P.S. le handle est basé sur l'existance du repertoire marqué ou ? || Dans init****.ora, bien sur ! (Plusieurs reps possibles) || Choses a faire: Un package, minimum, pour automatiquement gerer || un repertoire, pour ne pas le definir dans la procedure. Compris ? || Radu Caulea, Platinum Technology, 1999 (vers trois heures du matin) || Ce package (utl...) fonctionne a partir de 7.3.xxx ! */ Type: Essais| Cible: UTL_FILE | SubType: | Desc: Utilisation du package UTL_FILE | #