2

I have a PostgreSQL table containing some binary data.

I need to get the content of "select content from repository where documentuniqueid='1.3.6.1.4.1.21367.2010.1.2.166.155015116013230039.13086'" as a binary feed.

Is there a way to do this?

Thank you.

2
  • 1
    I'm not sure how it works directly within psql, but most programming languages will let you get binary data from blobs. It depends on the programming language. Which one are you using? Commented Jun 21, 2011 at 19:07
  • mmm... the simplest? I use Java. Isn't there any other way except to program something? Commented Jun 21, 2011 at 19:09

2 Answers 2

2

If you're using Java, you'll find some documentation about handling BLOBs via JDBC in the PostgreSQL JDBC driver documentation (e.g. via an InputStream).

You may also be interested in this question: Postgresql, JDBC, and streaming BLOBs

If you're not necessarily using Java, you may be interested in lo_export(), as @marto said.

Sign up to request clarification or add additional context in comments.

2 Comments

ALTER TABLE repository ADD COLUMN "content" bytea; So stored as byte stream.
As the documentation says, you should be able to extract the data using either ResultSet.getBytes(...) or ResultSet.getBinaryStream(...), depending on whether you want to read the result as a byte[] or an InputStream (however it was stored there in the first place doesn't really matter).
1

Stored in a Blob I assume?

lo_export()

1 Comment

ALTER TABLE repository ADD COLUMN "content" bytea;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.