Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
07-15-2022 02:21 PM
Is it possible to force a transaction to fail within the Cypher query itself.
The use case is a write transaction that makes some changes to the graph and then at the end of the query uses apoc.nodes.cycles to check to see if any cycles were introduced. If so, then I'd like to fail the transaction.
Michael-
07-15-2022 03:16 PM
I don't believe so in Neo4j Browser, as it uses implicit transactions, which are auto-close. I don't know of a command to rollback the changes.
The cypher-shell uses explicit transactions, where you have to manage the transactions. You could either commit or rollback the changes based on your outcome.
https://neo4j.com/docs/cypher-manual/current/introduction/transactions/
07-20-2022 01:40 PM
You can abort a cypher statement by using apoc.util.validate within the statement.
07-21-2022 04:20 PM
You can try MERGE statement with null value.
MERGE (n:StopExecution {id: $not_a_valid_param})
This will throw an exception and aborts the transaction as you cannot do a MERGE with null values.
All the sessions of the conference are now available online