1. 程式人生 > >Mysql報錯問題排查

Mysql報錯問題排查

1、sql_mode問題

SET @v_rowcount = 0;
  select count(*) into @v_rowcount from dual
    where exists (select * from businstep where finance_type='5' and businflow_id='0' and step_no=3);
SET @sql = IF(@v_rowcount = 0,"insert into businstep(finance_type,businflow_id,step_no,step_name,step_caption,menu_id,warn_type,pre_step_str,auto_flag) values('5','0',3,'期貨清算入賬',' ',210106,'0',' ','1');
	","update businstep set step_name='期貨清算入賬' , step_caption=' ' , menu_id=210106 , warn_type='0' , pre_step_str=' ' , auto_flag='1' where finance_type='5' and businflow_id='0' and step_no=3;");
PREPARE stmt FROM @sql;
EXECUTE stmt;

執行的時候報如下錯誤:

原因是: sql_mode=oracle 不支援雙引號

解決方式為:修改Mariadb的配置檔案配置檔案路徑:/etc/my.cnf.d/server.cnf),將原有oracle的配置模式中‘ANSI_QUOTES’去除,即將sql_mode的值修改為'PIPES_AS_CONCAT,IGNORE_SPACE,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,NO_AUTO_CREATE_USER' ;