Neo.ClientError.Statement.SyntaxError: Variable `timeTaken` not defined (line 2, column 46 (offset: 209)) "yield batches, total return batches, total , timeTaken , failedOperations , failedBatches , errorMessages , committedOperations , operations;" ^

Hello Team ,

I am trying to run the below query to get more information from the query but getting the below error -
Neo.ClientError.Statement.SyntaxError: Variable timeTaken not defined (line 2, column 46 (offset: 209))
"yield batches, total return batches, total , timeTaken , failedOperations , failedBatches , errorMessages , committedOperations , operations;"
^

CYPHER QUERY -

call apoc.periodic.iterate(" MATCH (c:CARD) , (p:PORT) where c.CARD_CI_NAME = p.PARENT_CI_NAME return c,p", "MERGE (c)-[r:card2port]->(p)" , {batchSize:1000})
yield batches, total return batches, total , timeTaken , failedOperations , failedBatches , errorMessages , committedOperations , operations;

You're trying to return variables, but most of those you haven't YIELDed from the iterate() call:

yield batches, total

Those are the only variables you've yielded from the call. In order to return the other variables YIELD them first from the call so they're in scope.

Hello Andrew,

May I know how to use the above variables in my query ? or if possible give me suitable example to use these variables correctly and efficiently in query.

Thanks!

Regards
AK

If you want all yielded variables, and the iterate() call is the only clause present, then just do the call and all the variables will be yielded and returned:

CALL apoc.periodic.iterate(" MATCH (c:CARD) , (p:PORT) where c.CARD_CI_NAME = p.PARENT_CI_NAME return c,p", "MERGE (c)-[r:card2port]->(p)" , {batchSize:1000});

Otherwise, YIELD all the variables you want to work with from the call, then use/return them:

CALL apoc.periodic.iterate(" MATCH (c:CARD) , (p:PORT) where c.CARD_CI_NAME = p.PARENT_CI_NAME return c,p", "MERGE (c)-[r:card2port]->(p)" , {batchSize:1000})
YIELD batches, total , timeTaken , failedOperations , failedBatches , errorMessages , committedOperations , operations
RETURN batches, total , timeTaken , failedOperations , failedBatches , errorMessages , committedOperations , operations;

Hello Andrew,

Thanks for the quick response and knowledge

Now I understood how to use the variables.

Is it also possible to add the custom variable? If yes , any suggested way to add?

Regards
Akshat

Procedures can only YIELD variables defined in the procedure's signature. You can always alias variables with the as keyword (for example, YIELD batches as importantVariable), and of course any variable you use in a MATCH pattern is added to scope as well.

You may want to go through the Cypher documentation first to get a better understanding of what you can do.

Hello Andrew,

Thanks a lot for your help and knowledge sharing !

Regards
Ak