stored procedures - How to use COLLATE in MySQL prepared statement -


i need specify collate in connection inside prepared statement inside stored procedure, e.g. <col> ? collate utf8_unicode_ci. i'm getting following error:

collation 'utf8_unicode_ci' not valid character set 'binary' 

i have tried cast parameter of: like _utf8 ? collate utf8_unicode_ci, like convert(? utf8) collate utf8_unicode_ci , like cast(? varchar character set utf8) collate utf8_unicode_ci error like:

you have error in sql syntax; check manual corresponds mysql server version right syntax use near 'varchar character set utf8) collate utf8_unicode_ci ... 

any hint appreciated.

afaik, _utf8 part of syntax string literals. since don't have, cannot use it.

the signature cast() this:

cast(expr type)

i think you want convert():

convert(expr,type), convert(expr using transcoding_name)

[...]

convert() using converts data between different character sets. in mysql, transcoding names same corresponding character set names. example, statement converts string 'abc' in default character set corresponding string in utf8 character set:

select convert('abc' using utf8); 

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -