# 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;" ^

**URL:** <https://community.neo4j.com/t/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/11610>\
**Category:** Procedures & APOC\
**Created:** [November 5, 2019, 6:43am UTC](https://community.neo4j.com/t/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/11610 "2019-11-05T06:43:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![akshat\_mittal](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/akshat_mittal/32/4359_2.png) [@akshat\_mittal](https://community.neo4j.com/u/akshat_mittal)\
**Post date:** [November 5, 2019, 6:43am UTC](https://community.neo4j.com/t/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/11610/1 "2019-11-05T06:43:46Z")

</div>

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;

---

<div class="post-metadata">

**Author:** ![andrew\_bowman](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/andrew_bowman/32/73_2.png) [@andrew\_bowman](https://community.neo4j.com/u/andrew_bowman)\
**Post date:** [November 5, 2019, 8:23am UTC](https://community.neo4j.com/t/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/11610/2 "2019-11-05T08:23:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![akshat\_mittal](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/akshat_mittal/32/4359_2.png) [@akshat\_mittal](https://community.neo4j.com/u/akshat_mittal)\
**Post date:** [November 5, 2019, 8:27am UTC](https://community.neo4j.com/t/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/11610/3 "2019-11-05T08:27:18Z")

</div>

> [@akshat\_mittal](#):
>
> 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;

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

---

<div class="post-metadata">

**Author:** ![andrew\_bowman](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/andrew_bowman/32/73_2.png) [@andrew\_bowman](https://community.neo4j.com/u/andrew_bowman)\
**Post date:** [November 5, 2019, 8:31am UTC](https://community.neo4j.com/t/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/11610/4 "2019-11-05T08:31:14Z")

</div>

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:

```auto
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:

```auto
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;

```

---

<div class="post-metadata">

**Author:** ![akshat\_mittal](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/akshat_mittal/32/4359_2.png) [@akshat\_mittal](https://community.neo4j.com/u/akshat_mittal)\
**Post date:** [November 5, 2019, 12:01pm UTC](https://community.neo4j.com/t/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/11610/5 "2019-11-05T12:01:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![andrew\_bowman](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/andrew_bowman/32/73_2.png) [@andrew\_bowman](https://community.neo4j.com/u/andrew_bowman)\
**Post date:** [November 5, 2019, 3:08pm UTC](https://community.neo4j.com/t/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/11610/6 "2019-11-05T15:08:59Z")

</div>

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](https://neo4j.com/docs/cypher-manual/current/) first to get a better understanding of what you can do.

---

<div class="post-metadata">

**Author:** ![akshat\_mittal](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/akshat_mittal/32/4359_2.png) [@akshat\_mittal](https://community.neo4j.com/u/akshat_mittal)\
**Post date:** [November 8, 2019, 7:57am UTC](https://community.neo4j.com/t/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/11610/7 "2019-11-08T07:57:22Z")

</div>

Hello Andrew,

Thanks a lot for your help and knowledge sharing !

Regards  
Ak
