简体   繁体   English

Neo4J / APOC - 调用存储过程`apoc.cypher.doIt`后无法构建查询

[英]Neo4J / APOC - Cannot build query after calling stored procedure `apoc.cypher.doIt`

I am running the following Cypher query: 我正在运行以下Cypher查询:

WITH "CREATE (test:Test {id: 1})" AS cypher
CALL apoc.cypher.doIt(cypher, {}) YIELD value
CREATE (test2:Test2 {id: 2})

Afterwards, I run MATCH (a) RETURN a and see that only one node, with Test label is created. 然后,我运行MATCH (a) RETURN a ,看到只有一个节点,创建了Test标签。 The second CREATE statement doesn't seem to be run. 似乎没有运行第二个CREATE语句。

If I create Test2 before the CALL , it does create the node as expected. 如果我在CALL 之前创建Test2 ,它会按预期创建节点。

Can anyone explain why this is occurring, and how one might continue on with a query after this CALL clause? 任何人都可以解释为什么会发生这种情况,以及在这个CALL子句之后如何继续查询?

Thanks in advance! 提前致谢!

The issue here is that since the cypher executed in apoc.cypher.doIt() doesn't return any rows, YIELD yields nothing. 这里的问题是,由于在apoc.cypher.doIt()中执行的密码不返回任何行,因此YIELD不会产生任何结果。 You can confirm this by replacing your CREATE at the end with RETURN value : No changes, no records. 您可以通过使用RETURN value替换最后的CREATE来确认这一点:无更改,无记录。

There are no rows to operate on, and all operations are performed per-row, so CREATE never gets executed, there are no rows to run it on. 没有要操作的行,并且所有操作都是按行执行的,因此CREATE永远不会被执行,没有行可以运行它。

You'll need to return something in your executed cypher, return true or something. 你需要在你执行的密码中返回一些东西, return true或者其他东西。

Always keep an eye out for how many rows your query is producing at various stages of your query, since your operations (match, create, etc) will be performed as many times as there are rows. 始终关注查询在查询的各个阶段产生的行数,因为您的操作(匹配,创建等)将执行与行数一样多的次数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM