Convert BLOB to text in sql

I have a field in my database table with datatype like BLOB

. How can I view the content as text/string

using a query SELECT

in SQL

. content MIMETYPE

is equal'text/xml charset=UTF8'

I tried with this, I'm not sure if it is correct with the syntax

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

      

and

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

      

many thanks

+3


source to share


5 answers


Try:



SELECT CONVERT(object USING utf8)
FROM tablename

      

+15


source


Try this query -



SELECT CONVERT(column USING utf8) FROM myTable WHERE ID=56

      

+3


source


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' is my field which was in BLOB type)

+1


source


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;

      

0


source


Set your content type in php:

header("Content-type: image/jpg"); //Send the content Type here.
print $data['blob_data'];

      

-1


source







All Articles