A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Murach's Java Servlets and JSP
this week in the
BLOB to String
Joined: Feb 28, 2009
Nov 18, 2009 06:54:55
Is it possible for someone to help me convert a BLOB to a
or readable text?
i am recieving this data from a queue.
Thanks in advance
Joined: Oct 02, 2009
Nov 18, 2009 08:06:03
Direct conversion is not possible without using some UDF, but you can extract text using SUBSTRING function:
DECLARE VARIABLE c1 VARCHAR(32000);
SELECT SUBSTRING(blob1 FROM 1 FOR 32000) FROM t1 INTO c1;
Please note that maximum length for VARCHAR is 32767 bytes (which might be less characters in multi-byte character sets like UTF8).
Various database access layers also have ability to retrieve BLOB data as string. For example, in PHP you could use:
$row = ibase_fetch_assoc($qry, IBASE_TEXT);
This automatically converts all textual BLOBs to VARCHARs, so you don't need to fetch blobs writing specific PHP code.
: Web-based Excel-like Java reporting tool.
Joined: Oct 27, 2005
Nov 18, 2009 09:08:54
A BLOB (binary large object) is binary data, so it could lead to problems when you convert it to text. If it should always be text a CLOB (character large object) is a better choice.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions
How To Answer Questions
Joined: Oct 13, 2005
Nov 18, 2009 09:23:27
Sounds like something database-related, so I shall move it to our databases forum.
It is sorta covered in the
JavaRanch Style Guide
subject: BLOB to String
Convertion of string object to BLOB
Oracle Datasource Connection
Convert String to Blob
conversion between CLOB/BLOB and String
How to store StringBuffer contents into a blob?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014