Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-08-2022 05:32 AM
I have a simple doubt.
Can't we write stored procedure in cypher itself and use it like other SQL databases?
Is using Java is the only option we have??
06-10-2022 01:53 PM
Yeah , Using java is the only option so far.
Here you will find a good instruction on how to do that easily
https://neo4j.com/developer-blog/lets-write-a-stored-procedure-in-neo4j-part-i/
06-10-2022 04:11 PM
Hi @suvi
This document is also helpful.
You can create your procedure by Cypher with APOC.
apoc.custom.asProcedure
https://neo4j.com/labs/apoc/4.4/overview/apoc.custom/apoc.custom.asProcedure/
06-13-2022 08:14 AM
I'm seeing a version mismatch when I attempt this.
The most recent of the jar that contains apoc.custom.asProcedure is
2022-06-11 18:32:25.708+0000 WARN [neo4j/cf363efa] The apoc version (4.4.0.5) and the Neo4j DBMS versions [4.4.6] are incompatible.
See the compatibility matrix in https://neo4j.com/labs/apoc/4.4/installation/ to see the correct version
It appears to me that I need to revert the version of Neo4J that I'm running all the way back to v4.4.0 in order to use anything in apoc.custom.
06-13-2022 09:39 AM
Hi @tms !
2 things:
1. You may like to use https://neo4j.com/labs/apoc/4.2/overview/apoc.custom/apoc.custom.declareProcedure/ instead.
2. It's a incorrect warning that will be solved soon. If you are planning on use this custom procedures you may like to use APOC 4.4.0.3 (Compatible with 4.4.6)
06-13-2022 11:53 AM - edited 06-13-2022 11:55 AM
The only plugin I have for APOC-4.4.0.3 is "apoc-4.4.0.3-core.jar". This is the "core" plugin, and does not include any apoc.custom methods. So far as I know, there is no "apoc-4.4.0.3-full.jar".
I'm under the perhaps incorrect impression that the "full" jar for 4.2 that you reference in your documentation URL is incompatible with neo4j enterprise v4.4.6.
So far as I know, this apoc.custom behavior is not currently available for neo4j enterprise 4.4.6.
06-13-2022 01:14 PM
@tms ,
2 things.
1. There's a full version of 4.4.0.3 here https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases
2. Also there, you can find the fresh out the oven 4.4.0.6
06-13-2022 01:56 PM
Hi @suvi
I checked with the same version.
Neo4j Enterprise 4.4.6
APOC 4.4.0.6 (Good for 4.4.6 now)
And I created the procedure.
https://neo4j.com/labs/apoc/4.4/overview/apoc.custom/apoc.custom.asProcedure/#usage-apoc.custom.asPr...
CALL apoc.custom.asProcedure(
'powers',
'UNWIND range(0, $power) AS power
RETURN $input ^ power AS answer',
'read',
[['answer', 'long']],
[['input','long'], ['power', 'long']]
);
CALL custom.powers(9, 3);
The result is here.
It works!!
06-10-2022 06:30 PM
Thanks @koji for that. I think this will work.
And also thanks to @Henrique for that article.
But now I wonder When should we use the Java implementation over the apoc custom procedure. Coz I feel former one is bit longer process. But I am sure there should be some advantage with the longer process.
would love to know what it is.
06-11-2022 04:38 AM
Hi @suvi!
Consider APOC as wrapper of your eventual implementation. At the end, it's a Java implementation on his own. In your use case, if the logic you want to wrap can be transform into Cypher predicates, you will be fine with APOC.
Some other cases may require a complex logic. In those scenarios you may need an implementation of your own. Learning how to do so will do no harm 😏
All the sessions of the conference are now available online