Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-06-2019 10:14 AM
While calling following query with param placeholder, it just ignores and does nothing (no exception) but harcoding values inside the query works fine.
Query (Parameterized):
"""
CALL apoc.periodic.iterate(
"MATCH (:Book)-[c:CONTAINS]->(:Instrument) RETURN c",
"SET c.eodMarkers = c.eodMarkers + date({eodDate}), c.states=c.states + {state}",
{batchSize: 20000}
)
"""
Called as tx.run(query, eodDate=someDate, state=someState)
But the following works: (values hardcoded inside query)
""" CALL apoc.periodic.iterate( "MATCH (:Book)-[c:CONTAINS]->(:Instrument) RETURN c", "SET c.eodMarkers = c.eodMarkers + date('2019-06-13'), c.states=c.states + 'ACTIVE'", {batchSize: 20000} ) """
Any idea why?
Solved! Go to Solution.
06-06-2019 10:24 AM
The scope used within the queries in iterate() is separate from the scope of the outermost query, and that includes query parameters.
You'll need to pass the parameters to use via the params
config property entry:
CALL apoc.periodic.iterate(
"MATCH (:Book)-[c:CONTAINS]->(:Instrument) RETURN c",
"SET c.eodMarkers = c.eodMarkers + date({eodDate}), c.states=c.states + {state}",
{batchSize: 20000, params:{eodDate:{eodDate}, state:{state}} }
)
We'd also encourage you to use the $state
style of parameter usage rather than {state}
.
06-06-2019 10:24 AM
The scope used within the queries in iterate() is separate from the scope of the outermost query, and that includes query parameters.
You'll need to pass the parameters to use via the params
config property entry:
CALL apoc.periodic.iterate(
"MATCH (:Book)-[c:CONTAINS]->(:Instrument) RETURN c",
"SET c.eodMarkers = c.eodMarkers + date({eodDate}), c.states=c.states + {state}",
{batchSize: 20000, params:{eodDate:{eodDate}, state:{state}} }
)
We'd also encourage you to use the $state
style of parameter usage rather than {state}
.
05-25-2022 08:02 PM
Thanks @andrew.bowman , my code as follows
delete_clause = """
CALL apoc.periodic.iterate(
"MATCH (c:City{name:$city})-[:BELONGTO]-(d:District)-[:LOCATE_AT]-(s:Shop) RETURN s",
"DETACH DELETE s",
{batchSize:10000, parallel:false, params:{city:$city}}
)
"""
tx.run(delete_clause, city=city)
Please note the city parameter.
All the sessions of the conference are now available online