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.

Syntax Exception while creating an apoc procedure inside a apoc trigger

I am creating an apoc procedure inside a apoc trigger. The error in the logs says this
"
org.neo4j.exceptions.SyntaxException: Variable node not defined (line 1, column 26 (offset: 25))
"MATCH(p1:SPerson { name: node.name}) CREATE (p1)-[:Enrolled]->(c)"

"

My apoc trigger code

 CALL apoc.trigger.add('loadEnrollments',   
"UNWIND apoc.trigger.nodesByLabel($assignedLabels, 'Enrollment') AS node
 MERGE (p1:SPerson { name: node.name, cell: node.cell, created_at: node.created_at})
 WITH p1, node
 MATCH (c:Course {name: 'Paradigm Shifting 101'})
 MATCH (n:SPerson)
 WITH p1, node, COUNT(n) as size
 CALL apoc.do.when(
 size>3,'MERGE (p1)-[:Waitlist]->(c)',
 'MATCH(p1:SPerson { name: node.name}) CREATE (p1)-[:Enrolled]->(c)') YIELD value
 DETACH DELETE node", 
 { phase: 'after' });
2 REPLIES 2

your apoc.do.when call lacks passing through the parameters for p1 and c, see https://neo4j.com/docs/labs/apoc/current/cypher-execution/conditionals/

Thanks Stefan. That worked.
Can you also please suggest me something on the following question. Your expertise is greatly appreciated.