问题描述
create or replace function get_sales_grouped_by_hour(beginningDate date,endDate date)
returns setof sales_grouped_by_hour as
$$
select hours,pharmacy_id,count(hours)
from (select * from sales_time_date_joined where beginningDate <= fulldate and fulldate <= endDate) as r1
group by pharmacy_id,hours
order by pharmacy_id,hours;
$$ language sql;
我想从 Java Spring Boot 服务器调用该函数,如下所示:
public List<Map<String,Object>> getSalesGroupedByHour(UUID pharmacyID,String beginningDate,String endDate) {
return jdbcTemplate.queryForList(
"SELECT * FROM get_sales_grouped_by_hour(?1,?2) WHERE pharmacy_id = ?3",beginningDate,endDate,pharmacyID);
}
请注意,我添加了一个 WHERE 条件来过滤函数给出的结果。 这会触发以下错误:
PreparedStatementCallback; bad sql grammar [SELECT * FROM get_sales_grouped_by_hour(?1,?2) WHERE pharmacy_id = ?3];
nested exception is org.postgresql.util.PsqlException: ERROR: Could not determine data type of parameter $4
这是为什么? 最简单的解决方法是什么?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)