4

The Cypher official documentation seems to be inconsistent and misleading when it comes to assigning parameter values..we have the following examples in the refcard:

SET n.property1 = $value1

where value1 is a parameter defined

{
 "value1": somevalue
}

However if you use this SET syntax you get an error value1 not defined. The correct syntax seems to be:

SET n.property1 = {value1}

also if its a MATCH query the parameter looks like this:

  {
     email: someemail
    }

note no quotes around email So if you have a MATCH and SET query with parameters you parameters definition looks like this:

{
email: someemail,
"status" : somestatus
}

Can someone explain this apparent inconsistency?

EDIT: This is also an example from the neo4j docs:

using parameter with SET clause:

{
  "surname" : "Taylor"
}

MATCH (n { name: 'Andres' })
SET n.surname = $surname
RETURN n

This returns surname undefined.

6
  • What version of Neo4j are you using? The $ syntax for params in Cypher was introduced in 3.x Commented Apr 5, 2017 at 16:37
  • I am using 3.0.8 and 3.1 Commented Apr 5, 2017 at 17:17
  • 1
    According to this, the $ syntax is valid from 3.1. Can you show how you are passing the parameters? Commented Apr 5, 2017 at 19:02
  • @cybersam you maybe right. I didn't actually run the 3.1 test as yet. So the 3.x according to William would not be correct....It would be 3.1+. for it to work I had to use the {value} which is not stated in the documentation that I saw.....maybe in some other documentation. And what with the different use of quotes("") when assigning values to the parameters? Commented Apr 5, 2017 at 20:24
  • Quotation depends, in part, on what language you are using to make your queries. Can you show the code you are using to pass the parameters? Commented Apr 5, 2017 at 20:38

1 Answer 1

4

You can set params in neo4j desktop browser using :params.

For eg,

  1. Execute, :params {surname: 'Taylor'}
  2. Execute, MATCH (n { name: 'Andres' }) SET n.surname = $surname RETURN n

For more info of params, use :help params

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.