虚位以待(AD)
虚位以待(AD)
首页 > 数据库 > DB2数据库 > 错误代码:1582 Incorrect parameter count in the call to native functio

错误代码:1582 Incorrect parameter count in the call to native functio
类别:DB2数据库   作者:码皇   来源:you23hai45(游海东)的专栏     点击:

1 错误描述1 queries executed, 0 success, 1 errors, 0 warnings查询:SELECT t `name`, DATE_FORMAT(str_to_date( & 039;2015 & 039;), & 039;%Y & 039;) as statisDate, ROUND(IFNULL(SUM(t `amount`), 0

1. 错误描述

    1 queries executed, 0 success, 1 errors, 0 warnings查询:SELECT t.`name`, DATE_FORMAT(str_to_date('
    2015'
    ), '
    %Y'
    ) as statisDate, ROUND(IFNULL(SUM(t.`amount`), 0), 3) AS ...错误代码: 1582Incorrect parameter count in the call to native function '
    str_to_date'
    执行耗时 : 0 sec传送时间 : 0 sec总耗时 : 0 sec

2. 错误原因

    SELECT t.`name`, DATE_FORMAT(STR_TO_DATE('
    2015'
    ), '
    %Y'
    ) AS statisDate, ROUND(IFNULL(SUM(t.`amount`), 0), 3) AS amountFROM t_stu_info t WHERE 1 = 1 AND DATE_FORMAT(t.statisDate, '
    %Y'
    ) = '
    2015'
    UNIONALL SELECT t.`name`, DATE_FORMAT(STR_TO_DATE('
    2014'
    ), '
    %Y'
    ) AS statisDate, ROUND(IFNULL(SUM(t.`amount`), 0), 3) AS amountFROM t_stu_info t WHERE 1 = 1 AND DATE_FORMAT(t.statisDate, '
    %Y'
    ) = '
    2014'

MySQL内置函数str_to_date的格式是:str_to_date(字符串,日期格式);
在这个查询SQL中却是str_to_date(字符串),导致报错

3. 解决办法

修改查询SQL语句

    SELECT t.`name`, DATE_FORMAT(STR_TO_DATE('
    2015'
    ,'
    %Y'
    ), '
    %Y'
    ) AS statisDate, ROUND(IFNULL(SUM(t.`amount`), 0), 3) AS amountFROM t_stu_info t WHERE 1 = 1 AND DATE_FORMAT(t.statisDate, '
    %Y'
    ) = '
    2015'
    UNIONALL SELECT t.`name`, DATE_FORMAT(STR_TO_DATE('
    2014'
    ,'
    %Y'
    ), '
    %Y'
    ) AS statisDate, ROUND(IFNULL(SUM(t.`amount`), 0), 3) AS amountFROM t_stu_info t WHERE 1 = 1 AND DATE_FORMAT(t.statisDate, '
    %Y'
    ) = '
    2014'
相关热词搜索: 错误 代码