I am trying to store a c++ byte array in a mySQL binary(16) field.
mysqlTable is an instance of mysqlx::Table class that works OK with other variable types.
data -> is the table field name of type binary(16)
data1 -> is the table field name of type binary(1)
What I have tried so far:
unsigned char cArray[16];
mysqlTable.insert("data").values(cArray).execute();
I have also tried:
unsigned char * pcArray = new unsigned char[16];
mysqlTable.insert("data").values(pcArray).execute();
And this works just fine:
unsigned char cOneChar;
mysqlTable.insert("data1").values(cOneChar).execute();
The error I get is form the compiler:
see reference to function template instantiation 'mysqlx::TableInsert &mysqlx::TableInsert::values<BYTE*>(BYTE *)' being compiled
error C2783: 'void mysqlx::internal::Args_processor<mysqlx::internal::Table_insert_detail::Add_value,mysqlx::internal::Table_insert_detail::Add_value::Impl *>::process_args(D,C)': could not deduce template argument for '__formal'
with
[
D=mysqlx::internal::Table_insert_detail::Add_value::Impl *
]
Does anyone know how to do this?
Late to the party but I struggled to find a neat way to do this. Using msqlx::bytes worked well. So you could adapt your code:
int n=16;
unsigned char cArray[n];
unsigned char const *Ptr=cArray;
mysqlx::bytes bytes{Ptr,n};
mysqlTable.insert("data").values(bytes).execute();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.