title: pgp_sym_encrypt and decrypt an entire column in postgresql
body: <p>I would like to encrypt an area_code column in my postgreSQL database with aes 256 encryption.
  Here is what happens.. I am able to encrypt it easily but I am not able to decrypt it.</p>
  <p>Here is the encryption query that works fine:</p>
  <pre><code>update mytable t1 set area_code = t2.area_code from (select pgp_sym_encrypt(area_code,'Password', 'compress-algo=1, cipher-algo=aes256') as area_code,area_name from mytable) t2 where t1.area_name = t2.area_name;
  </code></pre>
  <p>However the decryption query does not seem to work if I give something like</p>
  <pre><code>update mytable t1 set area_code = t2.area_code from (select pgp_sym_decrypt(area_code,'Password') as area_code,area_name from mytable) t2 where t1.area_name = t2.area_name;
  </code></pre>
  <p>or even when I try to view the decrypted area_code</p>
  <pre><code>select pgp_sym_decrypt((select area_code from ci), 'Password') ;
  </code></pre>
  <p>The only thing that works is when I use a single record and feed in the encrypted text directly as input.</p>
  <pre><code>select pgp_sym_decrypt('aes.encrypted.string.given.as.input', 'Password') ;
  </code></pre>