我需要根据查询日期
过滤掉Gemfire区域String queryString = SELECT * FROM /exampleRegion WHERE prcs_date =DATE $1;
QueryService queryService = cache.getQueryService();
Query query = queryService.newQuery(queryString);
Object[] params = new Object[1];
params[0] = "2018-05-03";
SelectResults results = (SelectResults)query.execute(params);
当我尝试执行它时,我收到以下异常
QueryInvalidException: Syntax error in query: expecting StringLiteral, found '$'
但是当我尝试运行硬编码查询select * from /exampleRegion where prcs_date= DATE '2018-05-03'
时,我能够得到结果
答案 0 :(得分:0)
我认为将字符串转换为日期的正确方法是使用to_date函数。这是一个例子:
SELECT * FROM /exampleRegion WHERE prcs_date = to_date($1, 'yyyy-MM-dd')