UTL_FILE.fgetattr fexists renvoie NULL
Bonjour,
J'ai un souci avec utl_file. (ora 9.0.2 sous linux)
Pour savoir si un fichier existe, j'ai voulu utiliser le FGetAttr
La doc du package est comme celle de Sheik
Citation:
UTL_FILE.FGETATTR(
repertoire IN VARCHAR2,
fichier IN VARCHAR2,
exists OUT BOOLEAN,
taille_fichier OUT NUMBER,
taille_bloc OUT NUMBER)
repertoire représente le répertoire Oracle
fichier représente le nom du fichier avec son extension
exists vaut TRUE si le fichier existe, sinon FALSE
taille_fichier représente la taille du fichier en octets
taille_bloc représente la taille d'un bloc système en octets
Cette fonction teste l'existence d'un fichier et récupère, dans l'affirmative, la taille du fichier et la taille du bloc système
Or ça ne marche pas :
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| DECLARE
fexists BOOLEAN;
file_length NUMBER;
block_size BINARY_INTEGER;
v_fic VARCHAR2(20) := 'fichier_inconnu';
BEGIN
UTL_FILE.FGETATTR('EEDI_WORK', v_fic, fexists, file_length, block_size);
IF fexists THEN DBMS_OUTPUT.PUT_LINE(v_fic ||' EXISTS '|| file_length || ' ' || block_size);
ELSIF NOT fexists THEN DBMS_OUTPUT.PUT_LINE(v_fic ||' NOT EXISTS '|| file_length || ' ' || block_size);
ELSIF fexists IS NULL THEN DBMS_OUTPUT.PUT_LINE(v_fic ||' NULL '|| file_length || ' ' || block_size);
END IF;
END; |
Code:
1 2 3
| fichier_inconnu NULL 0 0
40.txt EXISTS 1998 4096 |
Donc pour un fichier non trouvé, fexists vaut NULL et pas FALSE !!
C'est pareil chez vous ?