cancel
Showing results for 
Search instead for 
Did you mean: 

Use parameter :param with label and/or key?

rob2
Node Clone

Hi

can I use param for label and/or type?

:param NodeLabel => 'person';
:param RelType => 'has_mail';

MATCH (n1:$NodeLabel)-[r:$RelType]->(n2) RETURN r, n1, n2;

in the browser I get an error :

Neo.ClientError.Statement.SyntaxError: Invalid input '$': expected whitespace or a label name (line 1, column 11 (offset: 10))
"MATCH (n1:$NodeLabel)-[r:$RelType]->(n2) RETURN r, n1, n2"

Is there are trick?
thanks rob

1 ACCEPTED SOLUTION

Cobra
Ninja
Ninja

Hello @rob2

It is not possible to use a Label or a Type as a parameter in a MATCH clause.

Regards,
Cobra

View solution in original post

4 REPLIES 4

Cobra
Ninja
Ninja

Hello @rob2

It is not possible to use a Label or a Type as a parameter in a MATCH clause.

Regards,
Cobra

Thanks - also not in a where statement i guess ... rob

Cobra
Ninja
Ninja

Sorry, it's not possible in a MATCH clause but there is a workaround for WHERE clauses:

MATCH (n1)-[r]->(n2)
WHERE $NodeLabel IN LABELS(n1) AND type(r) = $RelType
RETURN r, n1, n2;

Regards,
Cobra

merci I will give it a try!

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.