List:MySQL++« Previous MessageNext Message »
From:Kévin Panhalleux Date:May 4 2010 9:49am
Subject:Blob Insertion Problem.
View as plain text  
Hi everybody
I'm trying to insert a massive set of integers into a mysql mediumblob using this code :

First i use this structure to store binary data :
> typedef struct bitStream 
> {
> 	char * data;
> 	int DataLength;
> } BitStream;
In which i'm writing my data into it :
>	int data[]={9,2,4,3,7,6,1,5,8}; // small samble can contain up to 100 000 values
>	BitStream myStream;
> = reinterpret_cast<char*>(data);
>	myStream.DataLength = sizeof(int)*9;

and then i finally insert the data using this :
> query << "INSERT INTO samples VALUES (1,2,3,\"" << mysqlpp::escape;
> query.write(myStream .data,myStream .DataLength);
> query << "\")";

Those lines works perfectly i'm able to write and read the data.
But as soon as i get a value which in binary is a multiple of 34 (it's the numerical value
for the symbol ") it give me this :
> Request error : You have an error in your SQL syntax; check the manual that
corresponds to your mySQL server version for the right syntax to use near '' at line1
(values causing request failure  are values in which the int are coded using 34 such as
290 (256+34) 8704 (34*256) etc)

I'm using blobs because the values are meaningless alone and they are only usefull when
they come alltogether that's why i'm using blo otherwise i would have used regular
columns.But since i have to retrieve as quickly as possible those data and that i only can
use them when i've all the values ... Blob seemed to be the perfect choice.

So my question is how do i get mysql to totally ignore any caracters contained into my
blob so it can insert properly.

Thanks for any answers.

Kévin Panhalleux.

Blob Insertion Problem.Kévin Panhalleux4 May
  • Re: Blob Insertion Problem.Jonathan Wakely4 May