【发布时间】:2015-06-05 20:33:36
【问题描述】:
我做了一个触发器验证了两列,当其中只有一个错误时它正常显示消息,当两个都错误时我得到错误
错误代码:1292。截断不正确的 INTEGER 值:''
我相信它在 Concat 部分我在函数上遗漏了什么吗?
if(RESULTADO = false) then
set msg = "Cpf invalido";
end if;
if(new.idadeproprietario <18) then
set msg2 = "Idade invalida";
end if;
if (msg is not null) or (msg2 is not null) then
select Concat(msg, msg2) into msg3;
Signal sqlstate '40000' set message_text = msg3;
end if;
【问题讨论】:
-
concat 将在任一值为 null 时返回 Null,您可能需要将 msg 和 msg2 合并为空集,例如 `select Concat(coalesce(msg,'',coalesce(msg2,'''))进入 msg3;另一篇关于主题的堆栈文章...stackoverflow.com/questions/15741314/…
-
@xQbert 它起作用了,只是需要改变一些东西,以供将来参考 select Concat(coalesce(msg,''),coalesce(msg2,'')) into msg3;
标签: mysql concatenation concat