Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2013
    Posts
    25

    Unanswered: BLOB to Text in mysql

    I have a column in mysql which has the datatype BLOB.I am using crystal reports for some reports. My problem is BLOB column will show blank data if it contains data other than a picture. The data I am getting from DB is text only.So I want to convert the BLOB column to some other datatype which will occupy more data like BLOB object. Please suggest what datatype I can conevrt.

    I tried this query but not working .Please help

    SELECT CAST(key_initiatives AS MEDIUMTEXT) key_init FROM OBJSETTING_FOCUS_ON_CUSTOMER

  2. #2
    Join Date
    Dec 2013
    Posts
    14
    You can write a function that will convert and then use it in your select
    DELIMITER $$

    CREATE FUNCTION BLOB2TXT (blobfield VARCHAR(255)) RETURNS longtext
    DETERMINISTIC
    NO SQL
    BEGIN
    RETURN CAST(blobfield AS CHAR(10000) CHARACTER SET utf8);
    END
    $$

  3. #3
    Join Date
    Mar 2013
    Posts
    25
    Hi Abhi,

    I did like this and it is working.I gave size as 65535 .Please suggest it is correct or not.

    SELECT CAST(KEY_INITIATIVES AS CHAR(65535) CHARACTER SET utf8 ) key_init FROM OBJSETTING_FOCUS_ON_CUSTOMER

  4. #4
    Join Date
    Dec 2013
    Posts
    14
    Hello Divyavani,

    If really required you can give such high value. Depends on your requirement.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •