In PL SQL, an uncompress of a too big file raise an error
From: <binpush3_at_gmail.com>
Date: Fri, 4 Sep 2015 08:40:55 -0700 (PDT)
Message-ID: <c5d39dcc-6b50-4f2f-8a83-b27f8495ab11_at_googlegroups.com>
Hello,
I try to uncompress file using the commands utl_compress.lz_uncompress. I manage to uncompress small file, lesser than a blob max size. But when I test the program with a bigger file, I'm having the error ORA-29294: A data error occurred during compression or uncompression.
BEGIN
BEGIN
END decompression_fichier; Received on Fri Sep 04 2015 - 17:40:55 CEST
Date: Fri, 4 Sep 2015 08:40:55 -0700 (PDT)
Message-ID: <c5d39dcc-6b50-4f2f-8a83-b27f8495ab11_at_googlegroups.com>
Hello,
I try to uncompress file using the commands utl_compress.lz_uncompress. I manage to uncompress small file, lesser than a blob max size. But when I test the program with a bigger file, I'm having the error ORA-29294: A data error occurred during compression or uncompression.
I don't manage to test the size of the blob, before the command "utl_compress.lz_uncompress".
I have put some dbms_output to follow what happens. Here is the results when just before the error raise :
SH.20150402182321.dat.gz ouvert
taille_restant_1309178
taille_a_lire_32000
postion_lecture_32001
taille_restant_1277178
taille_a_lire_32000
postion_lecture_64001
I don't know what to do more, help !
Ben
FUNCTION decompression_fichier (interface_ IN VARCHAR2,
nom_fichier_src_ IN VARCHAR2,
nom_fichier_cible_ IN VARCHAR2,
chemin_ IN VARCHAR2)
RETURN BOOLEAN IS
pointeur_fic_src_ BFILE;
contenu_compresse_ BLOB;
contenu_decompresse_ RAW (32000);
pos_depart_src_ INTEGER := 1;
pos_depart_dst_ INTEGER := 1;
taille_contenu_ INTEGER;
taille_restant_ INTEGER;
taille_a_lire_ INTEGER;
taille_lecture_ INTEGER := 32000;
taille_maxlob_ INTEGER := 32000;
v_file UTL_FILE.file_type;
contenu_lu_ RAW (32000);
postion_lecture_ INTEGER := 1;
lecture_ BOOLEAN;
BEGIN
BEGIN
DBMS_LOB.CREATETEMPORARY (contenu_compresse_, TRUE);
DBMS_LOB.OPEN (contenu_compresse_, DBMS_LOB.LOB_READWRITE);
pointeur_fic_src_ := BFILENAME (chemin_, nom_fichier_src_);
DBMS_LOB.fileopen (pointeur_fic_src_, DBMS_LOB.file_readonly);
IF DBMS_LOB.fileexists (pointeur_fic_src_) = 1
THEN
DBMS_OUTPUT.put_line (nom_fichier_src_ || ' ouvert');
v_file := UTL_FILE.fopen (chemin_, nom_fichier_cible_, 'wb');
taille_restant_ := DBMS_LOB.getlength (pointeur_fic_src_);
DBMS_LOB.loadblobfromfile (contenu_compresse_,
pointeur_fic_src_,
DBMS_LOB.GETLENGTH (pointeur_fic_src_),
pos_depart_src_,
pos_depart_dst_);
lecture_ := TRUE;
WHILE lecture_
LOOP
IF taille_restant_ < taille_maxlob_
THEN
taille_a_lire_ := taille_restant_;
lecture_ := FALSE;
ELSE
taille_restant_ := taille_restant_ - taille_maxlob_;
taille_a_lire_ := taille_maxlob_;
END IF;
DBMS_OUTPUT.put_line ('taille_restant_' || taille_restant_);
DBMS_OUTPUT.put_line ('taille_a_lire_' || taille_a_lire_);
DBMS_LOB.READ (contenu_compresse_,
taille_a_lire_,
postion_lecture_,
contenu_lu_);
postion_lecture_ := postion_lecture_ + taille_a_lire_;
DBMS_OUTPUT.put_line ('postion_lecture_' || postion_lecture_);
--
contenu_decompresse_ := utl_compress.lz_uncompress (contenu_lu_);
DBMS_OUTPUT.put_line (UTL_RAW.cast_to_varchar2 (contenu_decompresse_));
UTL_FILE.put_raw (v_file, contenu_decompresse_);
UTL_FILE.fflush (v_file);
END LOOP;
UTL_FILE.fclose (v_file);
DBMS_LOB.fileclose (pointeur_fic_src_);
END IF;
DBMS_LOB.FREETEMPORARY (contenu_compresse_);
-----------------
RETURN TRUE;
EXCEPTION
WHEN OTHERS
THEN
IF UTL_FILE.is_open (v_file)
THEN
UTL_FILE.fclose (v_file);
END IF;
--
IF (DBMS_LOB.fileisopen (pointeur_fic_src_) = 1)
THEN
DBMS_LOB.fileclose (pointeur_fic_src_);
END IF;
RETURN FALSE;
END;
END decompression_fichier; Received on Fri Sep 04 2015 - 17:40:55 CEST
