month这个参数没有用到,本来存储过程比这要长,我只是贴出了出错的部分

解决方案 »

  1.   

    问题解决了,原来是输入参数的year和列名的Year混淆了(大小写不同),把原来的参数year和month改为para_year和para_month就好了mysql> Drop Procedure If Exists p_report;
    Query OK, 0 rows affected (0.00 sec)mysql>
    mysql> Delimiter forend
    mysql>
    mysql> Create Procedure p_report
        ->  (In para_year Int,
        ->  In para_month Int,
        ->  In Id Char(10),
        ->  Out status Int)
        -> Begin
        ->  Select  Year,
        ->          Month,
        ->          OfficeId,
        ->          OnTimeRate
        ->  From    ReportByMonth
        ->  Where   OfficeId = Id And
        ->          Year = para_year;
        ->
        -> End
        ->
        -> forend
    Query OK, 0 rows affected (0.00 sec)mysql>
    mysql> Delimiter ;
    mysql>
    mysql> call p_report(2005,0,"1",@a);
    +------+-------+----------+------------+
    | Year | Month | OfficeId | OnTimeRate |
    +------+-------+----------+------------+
    | 2005 |     1 | 1        |          1 |
    | 2005 |     2 | 1        |          3 |
    | 2005 |     3 | 1        |          4 |
    | 2005 |     4 | 1        |          5 |
    | 2005 |     5 | 1        |          6 |
    | 2005 |     6 | 1        |          7 |
    | 2005 |     7 | 1        |          8 |
    +------+-------+----------+------------+
    7 rows in set (0.00 sec)Query OK, 0 rows affected (0.09 sec)