cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How to define constants in cypher

canbax
Node Link

I want to define constant values in a cypher query and use it multiple times inside different statements. Is that possible ? How can I do that ?

1 ACCEPTED SOLUTION

canbax
Node Link

I think I just find it. WITH statement can be used for such purpose

WITH round(rand()*10000000) as d1

MATCH ()-[e]-()
WHERE NOT EXISTS(e['start_time'])
SET e.start_time = d1
return e
limit 1 

View solution in original post

2 REPLIES 2

canbax
Node Link

I think I just find it. WITH statement can be used for such purpose

WITH round(rand()*10000000) as d1

MATCH ()-[e]-()
WHERE NOT EXISTS(e['start_time'])
SET e.start_time = d1
return e
limit 1 

You've got it.

Let me frame it differently for you -- Cypher doesn't really do variable assignment, so just about everything is a constant in cypher, in that you can't mutate variables, unless you alias them under other names.