Variable collation with MySQL stored procedure?
Posted
by Chad Johnson
on Stack Overflow
See other posts from Stack Overflow
or by Chad Johnson
Published on 2010-05-30T04:15:13Z
Indexed on
2010/05/30
4:22 UTC
Read the original article
Hit count: 547
mysql
|stored-procedures
I want to do something like this in a stored procedure:
IF case_sensitive = FALSE THEN
SET search_collation = "utf8_unicode_ci";
ELSE
SET search_collation = "utf8_bin";
END IF;
INSERT INTO TABLE1 (field1, field2)
SELECT * FROM TABLE 2 WHERE some_field LIKE '%rarf%' collate search_collation;
However, when I do this, I get
ERROR 1273 (HY000): Unknown collation: 'search_collation'
How can I use a dynamic collation without having two copies of the same query?
© Stack Overflow or respective owner