【问题标题】:Error Code: 1292. Truncated incorrect INTEGER value: ''错误代码:1292。截断不正确的 INTEGER 值:''
【发布时间】: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


【解决方案1】:

改变

select Concat(msg,msg2) into msg3;

select Concat(msg,msg2) as msg3;

这应该可以解决问题。

【讨论】:

  • 错误代码:1415。不允许从触发器返回结果集
【解决方案2】:
Warning (Code 1292): Truncated incorrect INTEGER value: '<Some Value>'

我在使用 CTAS 创建表时收到此警告作为错误,同时将数据插入到已创建的表中。

这是由于在列值上使用了count() 而发生的。使用Sum() 方法而不是count()

通常,Select 语句给出没有错误的输出,但它给出了Warning(可以通过启用警告\W 来检查)。这会在INSERT/CTAS 时出错。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-10-26
    • 2013-04-11
    • 2017-10-24
    • 1970-01-01
    • 1970-01-01
    • 2014-12-31
    • 2020-08-14
    • 1970-01-01
    相关资源
    最近更新 更多