3

I have a field in my database table with data type as BLOB.How can I view the content as text/string using a SELECT query in SQL. the content's MIMETYPE is 'text/xml charset=UTF8'

I tried with this, I'm not sure if im right with the syntax

SELECT 
CAST((SELECT column FROM myTable WHERE ID='56')AS CHAR(10000) CHARACTER SET utf8)

and also

SELECT 
CONVERT(VARCHAR(max), CAST((SELECT column FROM myTable WHERE ID='56') 
as binary)) from BIZDOCCONTENT

many Thanks

5 Answers 5

17

Try:

SELECT CONVERT(object USING utf8)
FROM tablename
2
  • what do I give in place of object?
    – shockwave
    Feb 14, 2013 at 9:25
  • 2
    Should just be the column containing your blog. :) Feb 14, 2013 at 16:26
3

Try this query -

SELECT CONVERT(column USING utf8) FROM myTable WHERE ID=56
2
  • I tried this but, I get an error saying right parenthesis missing. The syntax is proper. What mite be the error?
    – shockwave
    Feb 14, 2013 at 9:25
  • Yes, syntax is correct, query query should work. Try to run this command in another MySQL client, e.g. in command-line client.
    – Devart
    Feb 14, 2013 at 10:05
1

I had the same problem - I just changed the field type in phpmyadmin! And what i see :

ALTER TABLE pages CHANGE content content TEXT NULL DEFAULT NULL
('content' - my field which was in BLOB-type)

0
CREATE OR REPLACE FUNCTION HASTANE.getXXXXX(p_rowid in rowid) RETURN VARCHAR2
AS
    l_data long;
BEGIN
    SELECT XXXXXX INTO l_data FROM XXXXX WHERE rowid = p_rowid;
    RETURN substr(l_data, 1, 4000);
END getXXXXXX;
-2

Set your content type in php:

header("Content-type: image/jpg"); //Send the content Type here.
print $data['blob_data'];
1
  • I am not using PHP! Is there anything I can do about this in java/ sql. Please help!
    – shockwave
    Feb 14, 2013 at 9:27

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.