# Neo4J beginner: issues with CALL apoc.create.relationship

**URL:** <https://community.neo4j.com/t/neo4j-beginner-issues-with-call-apoc-create-relationship/15164>\
**Category:** Procedures & APOC\
**Created:** [February 28, 2020, 5:45am UTC](https://community.neo4j.com/t/neo4j-beginner-issues-with-call-apoc-create-relationship/15164 "2020-02-28T05:45:43Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![warwick.matthews](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/warwick.matthews/32/4379_2.png) [@warwick.matthews](https://community.neo4j.com/u/warwick.matthews)\
**Post date:** [February 28, 2020, 5:45am UTC](https://community.neo4j.com/t/neo4j-beginner-issues-with-call-apoc-create-relationship/15164/1 "2020-02-28T05:45:44Z")

</div>

`CALL apoc.load.xls('file:///filename.xlsx','Nodes') YIELD map as m

CALL apoc.create.node([m.fromNodeLabel], {name:m.fromNodeName,value:m.fromValue,instanceID:m.InstanceID}) YIELD node as f

CALL apoc.merge.node.eager([m.toNodeLabel], {name:m.toNodeName,instanceID:m.InstanceID}) YIELD node as t

**CALL apoc.create.relationship(f,m.relship,{weight:10}, t)**`

Variables YIELDed by the Create & Merge statements cannot be passed into the create.relationship statement without...something...?

---

<div class="post-metadata">

**Author:** ![ganesanmithun323](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/ganesanmithun323/32/5414_2.png) [@ganesanmithun323](https://community.neo4j.com/u/ganesanmithun323)\
**Post date:** [February 28, 2020, 8:53am UTC](https://community.neo4j.com/t/neo4j-beginner-issues-with-call-apoc-create-relationship/15164/2 "2020-02-28T08:53:44Z")

</div>

warwick ,  
could you please share the error you are getting .

---

<div class="post-metadata">

**Author:** ![intouch\_vivek](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/intouch_vivek/32/4097_2.png) [@intouch\_vivek](https://community.neo4j.com/u/intouch_vivek)\
**Post date:** [February 28, 2020, 11:43am UTC](https://community.neo4j.com/t/neo4j-beginner-issues-with-call-apoc-create-relationship/15164/3 "2020-02-28T11:43:51Z")

</div>

Hi warwick,

Please mention Yield for apoc.create.relationship(f,m.relship,{weight:10}, t)  
i.e.,  
CALL apoc.load.xls('file:///filename.xlsx','Nodes') YIELD map as m CALL  
CALL apoc.create.node([m.fromNodeLabel], {name:m.fromNodeName,value:m.fromValue,instanceID:m.InstanceID}) YIELD node as f  
CALL apoc.create.node([m.toNodeLabel], {name:m.toNodeName,instanceID:m.InstanceID}) YIELD node as t  
CALL apoc.create.relationship(f,m.relship,{weight:10}, t) yield rel as rel return rel,f,t

---

<div class="post-metadata">

**Author:** ![warwick.matthews](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/warwick.matthews/32/4379_2.png) [@warwick.matthews](https://community.neo4j.com/u/warwick.matthews)\
**Post date:** [February 29, 2020, 5:24am UTC](https://community.neo4j.com/t/neo4j-beginner-issues-with-call-apoc-create-relationship/15164/4 "2020-02-29T05:24:52Z")

</div>

_Procedure call inside a query does not support naming results implicitly (name explicitly using `YIELD` instead) (line 4, column 1 (offset: 294))_  
_"CALL apoc.create.relationship(f,m.relship,{weight:10}, t)"_  
^

---

<div class="post-metadata">

**Author:** ![warwick.matthews](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/warwick.matthews/32/4379_2.png) [@warwick.matthews](https://community.neo4j.com/u/warwick.matthews)\
**Post date:** [February 29, 2020, 5:27am UTC](https://community.neo4j.com/t/neo4j-beginner-issues-with-call-apoc-create-relationship/15164/5 "2020-02-29T05:27:57Z")

</div>

> [@intouch\_vivek](#):
>
> yield rel as rel return rel,f,t

That did it - I did not realise you must include a YIELD on the APOC create.  
THANK YOU!

---

<div class="post-metadata">

**Author:** ![anthapu](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/anthapu/32/4113_2.png) [@anthapu](https://community.neo4j.com/u/anthapu)\
**Post date:** [February 29, 2020, 5:09pm UTC](https://community.neo4j.com/t/neo4j-beginner-issues-with-call-apoc-create-relationship/15164/6 "2020-02-29T17:09:25Z")

</div>

If you are running a procedure all by itself then you don't need to do yield. If you are using somewhere in the middle of a cypher query you need to do yield.

---

<div class="post-metadata">

**Author:** ![warwick.matthews](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/warwick.matthews/32/4379_2.png) [@warwick.matthews](https://community.neo4j.com/u/warwick.matthews)\
**Post date:** [February 29, 2020, 10:03pm UTC](https://community.neo4j.com/t/neo4j-beginner-issues-with-call-apoc-create-relationship/15164/7 "2020-02-29T22:03:58Z")

</div>

> [@intouch\_vivek](#):
>
> yield rel as rel return rel,f,t

This may sound like a stupid question - but how do we know exactly what is yielded by these calls? I could not find it in [11.4.&nbsp;Creating Data - Chapter&nbsp;11.&nbsp;Node, Relationship and Path Functions and Procedures](http://neo4j-contrib.github.io/neo4j-apoc-procedures/3.5/nodes-relationships/data-creation/)

---

<div class="post-metadata">

**Author:** ![intouch\_vivek](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/intouch_vivek/32/4097_2.png) [@intouch\_vivek](https://community.neo4j.com/u/intouch_vivek)\
**Post date:** [February 29, 2020, 11:19pm UTC](https://community.neo4j.com/t/neo4j-beginner-issues-with-call-apoc-create-relationship/15164/8 "2020-02-29T23:19:18Z")

</div>

Please go through this link for YIELD [https://neo4j.com/docs/cypher-manual/current/clauses/call/](https://neo4j.com/docs/cypher-manual/current/clauses/call/)

If you need to use the output of a procedure use Yield. This use could be in Return statement or in other query etc.

Procedure apoc.create.relationship can just give you output node or relationship and that is what I did. In the neo4j documentation details of Yield is only given for generic procedures like CALL apoc.create.uuids(count) YIELD uuid, row.

---

<div class="post-metadata">

**Author:** ![anthapu](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/anthapu/32/4113_2.png) [@anthapu](https://community.neo4j.com/u/anthapu)\
**Post date:** [February 29, 2020, 11:19pm UTC](https://community.neo4j.com/t/neo4j-beginner-issues-with-call-apoc-create-relationship/15164/9 "2020-02-29T23:19:38Z")

</div>

There are 2 types of extensions in apoc.

Functions and Procedures.

Please see the documentation here  
[https://neo4j.com/docs/labs/apoc/current/overview/](https://neo4j.com/docs/labs/apoc/current/overview/)

Functions - They are inline functions that can return a single value.

Ex: apoc.node.degree.in

Functions can be used in where conditions, WITH etc.

Ex:

```auto
MATCH (n) WHERE apoc.node.degree.in(n, 'NEXT') > 0 

```

This query returns all the nodes which has more than one incoming NEXT relationship.

Procedures:  
These can return more than one values. Those values are handled using YIELD.

If you search in the doc you can find signature as

`apoc.create.relationship(from :: NODE?, relType :: STRING?, props :: MAP?, to :: NODE?) :: (rel :: RELATIONSHIP?)`

You can see the return value here as only one (rel :: RELATIONSHIP?)

Hope this explains it better.
