Re: How to convert ByteA to Large Objects

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How to convert ByteA to Large Objects
Date: 2009-01-23 14:58:01
Message-ID: 20090123145801.GK3008@frubble.xen.chris-lamb.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Jan 23, 2009 at 12:08:02PM +0000, Howard Cole wrote:
> Is there some nice SQL I can use to convert a BYTEA field into large
> objects?

You may be able to do something like:

SELECT oid, lowrite(lo_open(oid, 131072), (SELECT byteafield FROM tbl WHERE x)
FROM lo_create(NULL) o(oid);

You could turn this around to maybe do:

UPDATE tbl t SET newoid = (
SELECT oid FROM (
SELECT oid, lowrite(lo_open(oid, 131072), t.byteafield)
FROM lo_create(0) o(oid)) x);

--
Sam http://samason.me.uk/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sam Mason 2009-01-23 15:06:55 Re: deductive databases in postgreSQL
Previous Message Sam Mason 2009-01-23 14:45:39 Re: Using null or not null in function arguments