I get the following error for my cypher query (quoted below):
Invalid input 'p': expected
'n/N' or 's/S'
(line 1, column 116 (offset: 115))
"OPTIONAL MATCH (m:MeasurementSite)-[*2]-(v:Val)
WHERE ID(m) = $meter
AND v.d < $end
AND v.d > $start
WITH v, CALL
apoc.do.when(v IS NOT NULL,
'RETURN abs(toInteger(apoc.temporal.format(duration.inDays($date, $d), 'dd')))',
'RETURN null',
{d: v.d, date: $date}) AS dist
RETURN v, dist;"
The referenced p
is the second character in apoc
.
Link for CALL
is here. Does anybody know the problem and is it related to (wrong) quotes?
Seems like you can start a query with CALL apoc.do.when()
, but you cannot use it in somewhere in the middle of a query.
Working on version 4.
CALL clauses are for calling plugin procedures
(as opposed to functions
), and cannot be used in the middle of other clauses.
But, in addition, your WHERE
clause would filter out v
values that are NULL
anyway, so you don’t even need to test whether v
is NULL
(and your MATCH
does not need to be OPTIONAL
either).
Therefore, this should be good enough:
MATCH (m:MeasurementSite)-[*2]-(v:Val)
WHERE ID(m) = $meter
AND v.d < $end
AND v.d > $start
RETURN v, {d: v.d, date: $date} AS dist;