I feel like I'm being stupid, but I can't figure out how to conditionally call a (custom) procedure, and ensure a valid number is returned. Here's what I'm trying:

MATCH (a { uuid: "bad-uuid" })
RETURN CASE WHEN NOT a IS NULL
THEN CALL specialDelete(a) YIELD out
ELSE 0 END
AS out

That's a syntax error immediately after the CALL, but I get how this is bending the intent of CASE. This also does not work:

MATCH (a { uuid: "bad-uuid" })
CALL specialDelete(a) YIELD out
RETURN CASE WHEN out IS NULL
THEN 0
ELSE out END
AS out

Here, the return set is empty. This use case is for a Neo4jRepository @Query for a deleteBy function, and it really doesn't like an empty result. (What I'd really like to do is throw a 404, which I could probably do at the service layer, if I can avoid the 500 caused by the above.)