ibatis Error code '979'

 select substr(org_cd,0,$length$) as org_cd,sum(weight)/500000 as yksl from ds_move_store
 where data_state='0' and business_year=#year# group by substr(org_cd,0,#length#)

后台查询的时候出现了这个错误:

 [DEBUG] 2012-02-25 09:26:23 :Unable to translate SQLException with Error code '979', will now try the fallback translator
 [DEBUG] 2012-02-25 09:26:23 :Unable to translate SQLException with Error code '979', will now try the fallback translator
 [DEBUG] 2012-02-25 09:26:23 :Extracted SQL state class '42' from value '42000'
 [DEBUG] 2012-02-25 09:26:23 :Extracted SQL state class '42' from value '42000'
 [DEBUG] 2012-02-25 09:26:23 :Returning JDBC Connection to DataSource
 [DEBUG] 2012-02-25 09:26:23 :Returning JDBC Connection to DataSource

但是把语句放在数据库客服端就不会报错,

后来发现是sql语句写错了,函数里面substr(org_cd,0,#length#) 用了#号,这个会导致出来的语句会加上‘’,换成$$符号就可以了..

你可能感兴趣的:(sql,数据库,ibatis,jdbc,Class,returning)