Insert binary type data into MySQL database
32 views (last 30 days)
Show older comments
Dear all,
I can't figure out how to solve this issue:
I'm using matlab 2012b and my goal is to insert a value into a table's column of a MySQL database. The data type of this column is binary(2). Here you have my code:
conn=database('mysql_labview','','');
address = native2unicode(fliplr(typecast(uint16(hex2dec('0123')),'uint8')));
fastinsert(conn,'my_table',{'address'},{address});
close(conn)
I understand that native2unicode returns a string which is a char type and this is not compatible with column data type. I am able to do this operation in LabVIEW by using the byte array to string function but I need to do this operation in MATLAB too. I would really appreciate your comments and suggestions.
Thanks
Marco.
2 Comments
Guillaume
on 9 Feb 2015
I'm not clear on what you're trying to do. What is the data you're trying to write in your column, exactly? Here it looks like it is a single (non-unicode?) character, is that right?
If that is the case, why can't you just write the original bytes in the column?
Answers (0)
See Also
Categories
Find more on Database Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!