Creating a stored procedure with utf8 strings

14,172

Solution 1

adding ?characterEncoding=utf8 to the server url did the trick.

Solution 2

In store procedure input variable added

CHARSET utf8

So it look like this:

CREATE DEFINER=`root`@`%` PROCEDURE `post_content`(IN postName varchar(255), IN contentEn longtext, IN contentAR longtext CHARSET utf8, IN contentKU longtext CHARSET utf8)

...

Share:
14,172
Clemens Valiente
Author by

Clemens Valiente

Updated on July 11, 2022

Comments

  • Clemens Valiente
    Clemens Valiente almost 2 years

    I have a stored procedure with some Cyrillic strings inside. I want to check a table with a char column if the column contains some specific strings, some of them in Cyrillic. The problem seems to be that I cannot create the procedure with those strings.

    SET NAMES utf8;
    
    delimiter //
    drop procedure if exists testutf8
    //
    create procedure testutf8()
    begin
        select 'ξενοδοχια';
    end
    //
    delimiter ;
    
    
    call testutf8();
    

    Returns ?????????

    show create procedure testutf8;
    

    returns

    Procedure testutf8

    sql_mode STRICT_TRANS_TABLES

    Create Procedure "CREATE DEFINER=xxx@% PROCEDURE testutf8() begin select '?????????'; end"

    character_set_client utf8

    collation_connection utf8_general_ci

    Database Collation latin1_swedish_ci

    So despite me using SET NAMES UTF8; the server turns my code into latin1 it seems. How can I fix this?

  • Clemens Valiente
    Clemens Valiente almost 11 years
    This did not change the result, sorry