【发布时间】:2014-07-30 11:36:25
【问题描述】:
我正在构建一个 grails 应用程序并收到一个我真的无法理解的错误。
所以,我正在使用 ajax 调用,下拉列表将值发送到控制器。 控制器抛出错误:
NullPointerException occured when processing request POST
代码 #1
def com = Com.executeQuery("select p.date_hour, (sum(p.atc_visits)*100),
case when (sum(atc_visits_ly)) IN (0,null) THEN 0 ELSE (((sum(atc_visits))/(sum(atc_visits_ly)) - 1)*100*100) END as yoy,
case when (sum(atc_visits_lw)) IN (0,null) THEN 0 ELSE (((sum(atc_visits))/(sum(atc_visits_lw)) - 1)*100*100) END as wow,
p.mv, p.browser, p.department, p.platform, p.device, p.time_period from Com p where p.department = ? and p.time_period = ? group by p.date_hour order by col_0_0_ asc ",[params.department, params.time_period])
render com as JSON
代码 #2
def com = Com.executeQuery("select p.date_hour, (sum(p.atc_visits)*100),
case when (sum(atc_visits_ly)) IN (0,null) THEN 0 ELSE (((sum(atc_visits))/(sum(atc_visits_ly)) - 1)*100*100) END as yoy,
case when (atc_visits_lw) IN (0,null) THEN 0 ELSE ((atc_visits/atc_visits_lw - 1)*100*100) END as wow, p.mv, p.browser, p.department, p.platform, p.device, p.time_period from Com p where p.department = ? and p.time_period = ? group by p.date_hour order by col_0_0_ asc ",[params.department, params.time_period])
render com as JSON
在代码 #2 中,错误消失了,而在代码 #1 中,错误出现了,这是我在调试时意识到的。
唯一的区别是在代码#2 中,我将sum(atc_visits_lw) 更改为atc_visits_lw。但是这种聚合必须完成,在这种情况下很重要。
我也更改了 - atc_visits -> sum(atc_visits) 但这不会引发错误。
**错误只是因为:sum(atc_visits_lw) **
我查看了错误,并没有与我在这里遇到的类似的情况。 我可能在这里做错了什么?我该如何解决这个问题?
我在 sql 中运行了相同的查询并使用后端签入了 excel,但 atc_visits_lw 的值无处不在
非常感谢所有反馈
【问题讨论】:
-
@AnIshA 下次提出修改建议时,请解决问题可能存在的所有问题,而不仅仅是唾手可得的果实。