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.

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

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

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

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!