Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> uuencode/uudecode + Oracle
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);
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';
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
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"
-- http://www.freelists.org/webpage/oracle-lReceived on Mon Jan 24 2005 - 19:42:42 CST
![]() |
![]() |