5 messages in com.mysql.lists.plusplusRe: BLOB or TEXT, which I should chose
FromSent OnAttachments
Jan KC08 Nov 2003 03:27 
Tommy Tang08 Nov 2003 22:07 
Sinisa Milivojevic20 Nov 2003 05:39 
Tommy Tang20 Nov 2003 18:45 
Sinisa Milivojevic21 Nov 2003 06:13 
Subject:Re: BLOB or TEXT, which I should chose
From:Tommy Tang (tom@vlinetech.com)
Date:11/20/2003 06:45:04 PM
List:com.mysql.lists.plusplus

Yes, I know I should use blob, but the question is that I don't know how to
store a byte array (not char string because there is NULL char in the middle of the array) to the
database? As I found that the << operator of Query will end when encountering NULL
char(that is '\0'), doesn't eat the left data after the NULL char. So I use mysql_escape_string to convert the
byte stream. When I feed the converted stream to Query, the same result occured, that is the << operator
doesn't absorb the chars after char '0'(not '\0').

At last, I have to write a EscapeString() function by hand, in the function I
convert the '\0' to instead of the escape '\' and '0', so the byte stream becomes into the ordinary NULL terminated string, now I can save it to
database. When retrieving, I call anther function UnEscapeString() to restore. By this way, I work around the question, but I think it is clumsy
because it has nothing to do with blob, I can use text instead. So I wonder the existing meaning of blob filed. I think it should have another better
way.

Best Regards! Yours Sincerely Tommy

On Sun, 9 Nov 2003 14:07:57 +0800 "Tommy Tang" <tom@vlinetech.com> wrote:

In an instant communication application, I wanna store the messages from one person to another. The max length of the message is about 2K. I had thought that the TEXT is the best candidate to store the message, but the question arises because there are displaying format and font information included in the message, that is there may be several NULL terminated string in the message, or in another word message is a combination of text and number(such as font size and other displaying related properties), so I think it is better to chose BLOB as the type of the field because it is BINARY VARCHAR. But the the problems result from that choice is that how to manipulate the BLOB in Visual C++? Is there any API provided to store the BLOB and read the BLOB in sql++? In my application I store the message in a BYTE array, how can I insert it into the database using SQL?

Best Regards! Tommy

use BLOB

Sincerely,