# How to call a yield statement within apoc.iterate?

**URL:** <https://community.neo4j.com/t/how-to-call-a-yield-statement-within-apoc-iterate/43062>\
**Category:** Neo4j Graph Platform\
**Tags:** apoc, cypher, apocperiodiciterate\
**Created:** [August 18, 2021, 3:21am UTC](https://community.neo4j.com/t/how-to-call-a-yield-statement-within-apoc-iterate/43062 "2021-08-18T03:21:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ldj20](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/ldj20/32/19237_2.png) [@ldj20](https://community.neo4j.com/u/ldj20)\
**Post date:** [August 18, 2021, 3:21am UTC](https://community.neo4j.com/t/how-to-call-a-yield-statement-within-apoc-iterate/43062/1 "2021-08-18T03:21:46Z")

</div>

I'm wondering if it's possible to include something like apoc.create.setProperty or apoc.refactor.invert inside an iterate statement. Something like:

```auto
CALL apoc.periodic.iterate("MATCH ()-[rel:RELATED]->() RETURN rel", 
"CALL apoc.refactor.invert(rel) YIELD input, output RETURN input, output",
{batchSize:1000, parallel: true})
YIELD batches, total RETURN batches, total

```

Yield doesn't mesh well with the way iterate works so I can't think of a way to make this work. Anyone have any thoughts?

---

<div class="post-metadata">

**Author:** ![michael.hunger](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/michael.hunger/32/27377_2.png) [@michael.hunger](https://community.neo4j.com/u/michael.hunger)\
**Post date:** [August 19, 2021, 8:23pm UTC](https://community.neo4j.com/t/how-to-call-a-yield-statement-within-apoc-iterate/43062/2 "2021-08-19T20:23:46Z")

</div>

Sure, you just have to yield one of the result columns and `return a count(*)` to make it a valid statement.

changing rels in parallel might get you a lot of locking esp. before 4.3

```auto
CALL apoc.periodic.iterate("MATCH ()-[rel:RELATED]->() RETURN id(rel) as id", 
"MATCH ()-[rel:RELATED]->() WHERE id(rel) = id WITH * 
 CALL apoc.refactor.invert(rel) YIELD output RETURN count(*)",
{batchSize:1000, parallel: true})
YIELD batches, total RETURN batches, total

```
