Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-04-2019 10:43 PM
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;
11-05-2019 12:23 AM
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.
11-05-2019 12:27 AM
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
11-05-2019 12:31 AM
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;
11-05-2019 04:01 AM
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
11-05-2019 07:08 AM
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.
11-07-2019 11:57 PM
Hello Andrew,
Thanks a lot for your help and knowledge sharing !
Regards
Ak
All the sessions of the conference are now available online