Anyone tried the UTL_ENCODE package in Oracle ? In particular, trying to get it to decode a file that has been previously uuencoded via the OS. Example: Original file: f.doc (MS word document, 94208 bytes) Encoded with uuencode: f.uue (129823 bytes, done with Solaris 8) OS uudecode works fine so the encoded file is OK. Then tried to decode with the database, using UTL_ENCODE and UTL_FILE as per: SQL> declare 2 uue_file utl_file.file_type := utl_file.fopen('MY_DIR','f.uue','r'); 3 dest_file utl_file.file_type := utl_file.fopen('MY_DIR','new_file.doc','w',32767); 4 uue_line varchar2(80); 5 decoded_data raw(80); 6 bytes_written number := 0; 7 begin 8 loop 9 utl_file.get_line(uue_file,uue_line); 10 decoded_data := utl_encode.uudecode(utl_raw.cast_to_raw(uue_line)); 11 utl_file.put_raw(dest_file,decoded_data); 12 bytes_written := bytes_written + nvl(utl_raw.length(decoded_data),0); 13 exit when uue_line = 'end'; 14 end loop; 15 utl_file.fclose_all; 16 dbms_output.put_line('Bytes written = '||bytes_written); 17 end; 18 / Bytes written = 67860 PL/SQL procedure successfully completed. Hmmm...Result file seems a little small...and surprise, surprise, cannot be opened in Word. If I add debugging code for each line decoded: dbms_output.put_line( 'Text read '||length(uue_line)||' bytes, decoded to '|| utl_raw.length(decoded_data)||' bytes'); then the following appears in the output for each line: ... Text read 61 bytes, decoded to 33 bytes Text read 61 bytes, decoded to 33 bytes Text read 61 bytes, decoded to 31 bytes Text read 61 bytes, decoded to 33 bytes Text read 61 bytes, decoded to 31 bytes Text read 61 bytes, decoded to 31 bytes Text read 61 bytes, decoded to 33 bytes Text read 61 bytes, decoded to 31 bytes Text read 61 bytes, decoded to 31 bytes Text read 61 bytes, decoded to 33 bytes Text read 61 bytes, decoded to 31 bytes Text read 61 bytes, decoded to 32 bytes Text read 61 bytes, decoded to 31 bytes Text read 61 bytes, decoded to 31 bytes Text read 61 bytes, decoded to 33 bytes Text read 61 bytes, decoded to 32 bytes Text read 61 bytes, decoded to 31 bytes Text read 61 bytes, decoded to 31 bytes Text read 61 bytes, decoded to 31 bytes Text read 61 bytes, decoded to 31 bytes ... ... I'm pretty sure that uuencode turns 3 bytes into 4 (and this decoding turns 4 bytes into 3). Yet the above output suggests a halving in size... Can anyone spot any obvious silly things that I'm doing ? Cheers Connor ===== Connor McDonald Co-author: "Mastering Oracle PL/SQL - Practical Solutions" ISBN: 1590592174 web: http://www.oracledba.co.uk web: http://www.oaktable.net email: connor_mcdonald@xxxxxxxxx Coming Soon! "Oracle Insight - Tales of the OakTable" "GIVE a man a fish and he will eat for a day. But TEACH him how to fish, and...he will sit in a boat and drink beer all day" ------------------------------------------------------------ __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com -- //www.freelists.org/webpage/oracle-l