Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-14-2019 11:20 PM
Tried to put quotes in a query. Because I use one procedure inside another, I need to use quotes with variable fileName.
There is the error:
"Failed to invoke procedure apoc.periodic.iterate
: Caused by: org.neo4j.cypher.ParameterNotFoundException: Expected parameter(s): fileName"
The query:
@Query("CALL apoc.periodic.iterate('\n" +
" CALL apoc.load.json(\\\"{fileName}\\\") YIELD value as v RETURN v'\n" +
" ,'\n" +
" FOREACH ( i in CASE WHEN v.cat=true THEN [1] ELSE [] END | MERGE (c:C{id:v.id, version: {version}}))\n" +
" FOREACH ( i in CASE WHEN v.dog=true THEN [1] ELSE [] END | MERGE (c:Ca{id:v.id, version: {version}}))\n" +
" WITH v\n" +
...
void p(@Param("fileName") String fileName, @Param("version") String version);
I have tried several options:
{fileName}
\"{fileName}\"
"{fileName}"
But they don't work. How could I fix it?
This query works and parameter fileName is correct:
@Query("CALL apoc.load.json({fileName} ) YIELD value as v \n" +
"MERGE(c:C{name:v.id})\n" +
"RETURN v.id")
void p(@Param("fileName") String fileName);
10-20-2019 04:09 PM
Using apoc.periodic.iterate
you have to externally passing in a map of params, as shown at the end of the second last line. The following example works for me:
@Query(
"CALL apoc.periodic.iterate('\n" +
" CALL apoc.load.csv({ url }) yield map as row return row\n" +
"','\n" +
" CREATE (record:Record) SET record = row\n" +
"', {batchSize:10000, iterateList:true, parallel:true, params:{url:{url}}});\n")
void loadCsvData(@Param("url") String url);
All the sessions of the conference are now available online