Page 1 of 1

BLOB conversion when SaveToXML

Posted: Thu 20 Nov 2014 11:46
by rahucha
Hi,

I have a BLOB field in my table and I'm using TMyQuery.SaveToXML. The information in my BLOB field (MyField) is for example the string "Hello" and it's stored in the XML file as:

MyField="48656C6C6F"

(It seems that it's converting it to its hex ASCII char as string)

Anyway, at a later time I export from XML to my database (using "LOAD XML LOCAL INFILE....") and I get in "MyField" BLOB the content: 48656C6C6F (instead of the original string "Hello").

Is there any special parameter to read back the expected BLOB field string?

Thanks!

Re: BLOB conversion when SaveToXML

Posted: Fri 21 Nov 2014 05:25
by ViktorV
Thank you for the information. We will investigate the reason for such behavior.
As a workaround, you can map data with such types using 'Field Name' of the needed columns.
Example:

Code: Select all

MyQuery1.DataTypeMap.AddFieldNameRule(FieldName, ftWideString);
More details about Data Type Mapping can be found in the MyDAC documentation: http://www.devart.com/mydac/docs/data_type_mapping.htm

Re: BLOB conversion when SaveToXML

Posted: Fri 21 Nov 2014 11:46
by rahucha
Hi Viktor,

Thanks for the reply. That fixes the problem in a specific BLOB field that I have (where I just contain ASCII chars)

But I still have a problem where I have another BLOB field which contains HEX data (bytes for an image). I understand that you store the BLOB field as each HEX byte converted into ASCII (two bytes).

The problem is when I restore from the XML, the BLOB is not read correctly by "LOAD XML LOCALFILE....". So, it seems that MySQL is waiting for a different format for BLOB fields?

Thanks!

Re: BLOB conversion when SaveToXML

Posted: Fri 21 Nov 2014 20:41
by rahucha
Hi Viktor,

I have used a workaround and after loading the BLOB fields into the table from the XML file, I have converted your string "hex" format into binary data (using a TStream) and it worked fine.

I'm good with that :)

Thanks

Re: BLOB conversion when SaveToXML

Posted: Tue 30 Dec 2014 11:56
by ViktorV
We have added the TMyDataSetOptions.SaveBlobsAsHex property. Setting it to False you will be able to save the value of the BLOB field as string. We plan to release the new version of MyDAC within 2 weeks.