title: Oracle How to Uncompress Blob
body: <p>I'm extracting BLOB column from a Oracle table.</p>
  
  <p>Some of the blob values I'm getting are in right string characters.</p>
  
  <p>However some of the blob values are not displaying correct the string. It seems that these rows are <strong>"compressed"</strong>.</p>
  
  <pre><code>Table Name: TableA
  Column Name: ID,                Type: Number
  Column Name: BLOB_BINARY_VALUE, Type: BLOB
  Column Name: BLOB_COMPRESSED,   Type: Number
  </code></pre>
  
  <p>Here is the SQL I used:</p>
  
  <pre><code>Select BLOB_BINARY_VALUE FROM TableA WHERE ID =  1234567;
  </code></pre>
  
  <p>I also tried using:</p>
  
  <pre><code>Select TO_BLOB(BLOB_BIN_VALUE) FROM TableA WHERE ID =  1234567;
  </code></pre>
  
  <p>Example of Wrong Blob value I'm getting: (I trimmed the value below because of it's length)</p>
  
  <pre><code> öp‘CÇL.aÜÌIëÉ8gbÈ¨!ƒ™2fÌÀÌ…mc›cÆÌ:0óÆ
  :bØ&gt;n€7iØ¶1M9sÊÐ¢ÉSÐ”aÃ6gvôéÓ@;iÊÜY“Æ
  </code></pre>
  
  <p>I'm guessing that this BLOB is in compressed format.
  How can I uncompressed this kind BLOB?</p>
  
  <p>Thank you very much in advance.</p>
  
  <p><strong>UPDATE 1:</strong>
  Example of Correct Blob query which I'm also expecting from others:</p>
  
  <pre><code>{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 MS Shell Dlg;}}
  \viewkind4\uc1\pard\f0\fs20 MESSAGE HERE MESSAGE HERE MESSAGE HERE.   \par
  }
  </code></pre>
  
  <p><strong>UPDATE 2:</strong></p>
  
  <p>There is another column in the database named "BLOB_COMPRESSED". The rows that have "0"s are the ones displaying correct values. The rows that have "1"s are the ones displaying wrong values. So I'm guessing that the data is compressed. </p>
  
  <p><strong>UPDATE 3:</strong>
  I tried to follow the advise from this link but still getting like compressed string: <a href="https://stackoverflow.com/questions/828650/how-do-i-get-textual-contents-from-blob-in-oracle-sql?rq=1">How do I get textual contents from BLOB in Oracle SQL</a></p>
  
  <pre><code>Select utl_raw.cast_to_varchar2(dbms_lob.substr(BLOB_BIN_VALUE)) 
  FROM TableA 
  WHERE ID = 1234567;
  </code></pre>