title: PostgreSQL: from OID to Bytea
body: <p>We have decided to move from <code>OID</code>s in our PostgreSQL 9.0 database and use <code>bytea</code> columns instead. I'm trying to copy the data from one column to the other, but I can't figure out the right query. This is the closest I've gotten to:</p>
  
  <pre><code>update user as thistable set pkcs_as_bytea = (select array_agg(mylargeobject.data) from 
    (select * from pg_largeobject where loid = thistable.pkcs12_as_oid order by pageno) as mylargeobject) where thistable.pkcs12 is not null
  </code></pre>
  
  <p>And that gives me the following error message:</p>
  
  <pre><code>ERROR:  column "pkcs_as_bytea" is of type bytea but expression is of type bytea[]
  </code></pre>
  
  <p>What would be the right query then?</p>