错误代码:1267。非法混合的归类(utf8_general_ci,IMPLICIT)和(utf8_unicode_ci,IMPLICIT)用于操作' ='

时间:2015-11-18 08:31:21

标签: mysql stored-procedures

我们正在使用以下存储过程,并且所有提到的表都使用" Collat​​ion = utf8_general_ci"我们仍然遇到这个错误:

  

错误代码:1267。操作的非法混合(utf8_general_ci,IMPLICIT)和(utf8_unicode_ci,IMPLICIT)' ='

存储过程是:

    DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `AssignCallRates`()
begin
    declare countrycode varchar(8000);
        declare countryname varchar(8000);
        declare currencycode    varchar(8000);
        declare priceval    varchar(8000);
        declare mobileprice varchar(8000);
        declare landprice   varchar(8000);
        declare reccnt      int;
        DECLARE done INT DEFAULT FALSE;
        declare country_cursor cursor for select country_code,country_name from dialoone_countries;
        declare aud_cursor cursor for select convert(price,char) as price from tbl_rate_aud where quick_search=1 and trim(substring_index(`place`,'-',1)) = countryname LIMIT 0,2;
        declare euro_cursor cursor for select convert(price,char) as price from tbl_rate_euro where quick_search=1 and trim(substring_index(`place`,'-',1)) = countryname LIMIT 0,2;
        declare gbp_cursor cursor for select convert(price,char) as price from tbl_rate_gbp where quick_search=1 and trim(substring_index(`place`,'-',1)) = countryname LIMIT 0,2;
        declare usd_cursor cursor for select convert(price,char) as price from tbl_rate_dollar where quick_search=1 and trim(substring_index(`place`,'-',1)) = countryname LIMIT 0,2;
        declare continue handler for not found set done=TRUE;

        truncate table tbl_rates;

        open country_cursor;
        CountryLOOP: loop
            fetch country_cursor into countrycode,countryname;
                if done=TRUE then
                    close country_cursor;
                    leave CountryLOOP;
                end if;
                set mobileprice = "";
                set landprice="";
                set reccnt = 0;
                set priceval = "";
                open aud_cursor;
                AUDLOOP: loop
                    fetch aud_cursor into priceval;
                        if done = TRUE then
                            set done = FALSE;
                            close aud_cursor;
                            leave AUDLOOP;
                        end if;
                        set reccnt = reccnt + 1;
                        if reccnt = 1 then
                            set landprice=priceval;
                        end if;
                        if reccnt = 2 then
                            set mobileprice=priceval;
                        end if;
        end loop AUDLOOP;
                insert into tbl_rates (country_code,currency_code,mobile,land) values (countrycode,"AUD",mobileprice,landprice);

                set mobileprice = "";
                set landprice="";
                set reccnt = 0;
                set priceval = "";
                open euro_cursor;
                EUROLOOP: loop
                    fetch euro_cursor into priceval;
                        if done = TRUE then
                            set done = FALSE;
                            close euro_cursor;
                            leave EUROLOOP;
                        end if;
                        set reccnt = reccnt + 1;
                        if reccnt = 1 then
                            set landprice=priceval;
                        end if;
                        if reccnt = 2 then
                            set mobileprice=priceval;
                        end if;
        end loop EUROLOOP;
                insert into tbl_rates (country_code,currency_code,mobile,land) values (countrycode,"EUR",mobileprice,landprice);

                set mobileprice = "";
                set landprice="";
                set reccnt = 0;
                set priceval = "";
                open gbp_cursor;
                GBPLOOP: loop
                    fetch gbp_cursor into priceval;
                        if done = TRUE then
                            set done = FALSE;
                            close gbp_cursor;
                            leave GBPLOOP;
                        end if;
                        set reccnt = reccnt + 1;
                        if reccnt = 1 then
                            set landprice=priceval;
                        end if;
                        if reccnt = 2 then
                            set mobileprice=priceval;
                        end if;
        end loop GBPLOOP;
                insert into tbl_rates (country_code,currency_code,mobile,land) values (countrycode,"GBP",mobileprice,landprice);

                set mobileprice = "";
                set landprice="";
                set reccnt = 0;
                set priceval = "";
                open usd_cursor;
                USDLOOP: loop
                    fetch usd_cursor into priceval;
                        if done = TRUE then
                            set done = FALSE;
                            close usd_cursor;
                            leave USDLOOP;
                        end if;
                        set reccnt = reccnt + 1;
                        if reccnt = 1 then
                            set landprice=priceval;
                        end if;
                        if reccnt = 2 then
                            set mobileprice=priceval;
                        end if;
        end loop USDLOOP;
                insert into tbl_rates (country_code,currency_code,mobile,land) values (countrycode,"USD",mobileprice,landprice);
    end loop CountryLOOP;
    select "Query Executed Successfully";       
end$$
DELIMITER ;

此SP需要更新吗?

1 个答案:

答案 0 :(得分:0)

From other answer:存储过程参数的默认排序规则是utf8_general_ci,您不能混合排序规则,这意味着数据库/表可能是unicode。

首先尝试一下:

SELECT @@collation_database;

然后查看您正在使用的实际表的CREATE语句。

More Info