操作'='的非法混合排序(latin1_swedish_ci,IMPLICIT)和(utf8_general_ci,COERCIBLE);

时间:2015-12-21 15:23:30

标签: mysql stored-procedures utf-8 collation latin1

我有MySQL架构,默认字符集 utf8 和整理 utf8_general_ci 在其中我有多个表/列都有整理 latin1_swedish_ci

我还有一个存储过程接受VARCHAR作为参数 pi_hashid 。基于这个答案https://stackoverflow.com/a/21687188/1094300我想通过改变存储过程来加速程序执行

where d.hash_id = convert(pi_hashid using latin1) collate latin1_swedish_ci

但是在更改之后,我得到了非法混合排序的异常, 我再次修改了程序(恢复了更改)

where d.hash_id=pi_hashid

但它仍然给我例外。 为什么我无法还原更改,还有另一种方法可以解决此问题,而无需更改所有表/列以使其具有与架构相同的排序规则。

更新: SHOW CREATE PROCEDURE company_get

company_get,,"CREATE DEFINER=`root`@`%` PROCEDURE `company_get`( IN pi_hashId varchar(50) )
BEGIN

SELECT
        ce.duns_number as duns
       ,ce.hash_id
       ,ce.company_name                 

           ,ce.Telephone_number as telephone
       ,ce.Facsimile_number as facsimile
       ,ce.Full_line_of_business_description as lob_des
       ,ce.Trading_Description as sic_lob_description
       ,concat(ce.US72_SIC1,ce.US72_SIC2,ce.US72_SIC3,ce.US72_SIC4,ce.US72_SIC5,ce.US72_SIC6) as us_sic
       ,ce.US72_SIC1
       ,ce.US72_SIC2
       ,ce.US72_SIC3
       ,ce.US72_SIC4
       ,ce.US72_SIC5
       ,ce.US72_SIC6


        ,case when cast(ce.Registration_number as decimal(10,0)) > 0
                    then concat( ce.Registration_number_prefix
                        ,lpad(cast(ce.Registration_number as decimal(10,0))
                            ,8 - length(ce.Registration_number_prefix)
                            ,'0')
                    ) 
                else ''
                end as Registration_number
       ,ce.Immediate_parent_DUNS_number as immediate_parent_DUNS
       ,ce.Immediate_parent_name 
       ,ce.Immediate_parent_country
       ,ce.Ultimate_parent_country 
       ,ce.Ultimate_parent_DUNS_number as Ultimate_parent_DUNS
       ,ce.Ultimate_parent_name 
       ,ce.Nominal_Capital
       ,ce.Issued_capital
       ,ce.Annual_Return_date
       ,ce.Pretax_Profit_1 as Pretax_Profit_1
       ,'' as pretax_loss_indicator
       ,ce.Year_Started
       ,ce.Date_Of_Incorporation as incorporation_date
       ,ce.Description_of_Brands as brands_description
       ,ce.Turnover_1
       ,ce.Net_Assets_1
       ,ce.Employees_Company_1 as no_employess1
       ,ce.Non_Audit_Fee_1
       ,ce.Auditors_Name_1 
       ,ce.Statement_date_2 as previous_statement_date
           ,c.major_sector_description
       ,c.sub_sector_description
       ,c.market_sector_description


           ,if(ce.Flag_to_indicate_branch_financials_populated_with_HQ_financials='Y',ce.Ultimate_parent_name,'')as hq_name
       ,ce.Net_Worth_1 as networth
       ,ce.Net_Profit_1  as profit
       ,ce.Annual_Local_Sales as sales
       ,ce.Year_Started as yr_start



       ,if ( (select paf_udprn from uf_dnb.companies where hash_id=sha(ce.Immediate_parent_DUNS_number))>0,sha(ce.Immediate_parent_DUNS_number),NULL  )   as immediate_parent_hash_id
       ,if ( (select paf_udprn from uf_dnb.companies where hash_id=sha(ce.Ultimate_parent_DUNS_number))>0,sha(ce.Ultimate_parent_DUNS_number),NULL  ) as ultimate_parent_hash_id
       ,if ( (select paf_udprn from uf_dnb.companies where hash_id=sha(ce.Ultimate_parent_DUNS_number))>0,sha(ce.Ultimate_parent_DUNS_number),NULL  )   as hq_hash_id

        ,ce.Gross_Profit_1
        ,ce.Operating_Profits_1
        ,ce.Total_Assets_1
        ,ce.Total_Liabilites_1
        ,ce.Working_Capital_1
        ,ce.Retained_Profits_1
        ,ce.Trading_Style_1 
       ,c.paf_udprn 
       ,c.paf_subbuild 
       ,c.paf_buildname 
       ,c.paf_buildno 
       ,c.paf_sub_street 
       ,c.paf_street 
       ,c.paf_sub_locality 
       ,c.paf_locality
       ,c.paf_post_town 
       ,c.paf_region
       ,c.paf_postcode 
       ,c.paf_postal_county 
       ,c.paf_area
       ,c.paf_district
       ,c.paf_gre
       ,c.paf_grn 

 FROM
           uf_dnb.companies_extended ce
           join uf_dnb.companies c
           on ce.hash_id=c.hash_id
   WHERE 
           ce.hash_id=pi_hashid;
END",utf8,utf8_general_ci,utf8_general_ci

0 个答案:

没有答案