cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Using parameters within Apoc periodic iterate function

Hi Team,

I'm running the code below to try and load a new relationship from data in an external server. My Select_In parameter contains single quotes, hence why i'm not passing this directly into the query.
The parameter creates with no issues but when i try to run the apoc periodic iterate section i get the following error:-

Neo.ClientError.Procedure.ProcedureCallFailed: Failed to invoke procedure apoc.periodic.iterate: Caused by: org.neo4j.cypher.ParameterNotFoundException: Expected parameter(s): Select_In

I'm a Neo4J rookie so any pointers as to how to pass this parameter information in successfully would be appreciated.

:param Select_In => "select variables
   from (
         select variables_in
           from table_a a
              join table_b b
                on a.id=b.id
          where conditions)"

CALL apoc.periodic.iterate("
CALL apoc.load.jdbc('jdbc:oracle:thin:@server',
$Select_In,
[],
{credentials:{user: 'username', password: 'password'}}) YIELD row RETURN row
","
MATCH (co:Comp {id: row.ID}), (co1:Comp {id: row.ID2}
CREATE (co)-[:Relationship]->(co1)
", {batchSize:10000, iterateList:true, parallel:false})

Cheers,

Sam

1 ACCEPTED SOLUTION

You need to explicitly pass through the parameters to the inner statement using params in the map (3rd argument, last line):

:param Select_In => "select variables
   from (
         select variables_in
           from table_a a
              join table_b b
                on a.id=b.id
          where conditions)"

CALL apoc.periodic.iterate("
CALL apoc.load.jdbc('jdbc:oracle:thin:@server',
$Select_In,
[],
{credentials:{user: 'username', password: 'password'}}) YIELD row RETURN row
","
MATCH (co:Comp {id: row.ID}), (co1:Comp {id: row.ID2}
CREATE (co)-[:Relationship]->(co1)
", {batchSize:10000, iterateList:true, parallel:false, 
    params: {Select_In: $Select_In}
   })

View solution in original post

3 REPLIES 3

You need to explicitly pass through the parameters to the inner statement using params in the map (3rd argument, last line):

:param Select_In => "select variables
   from (
         select variables_in
           from table_a a
              join table_b b
                on a.id=b.id
          where conditions)"

CALL apoc.periodic.iterate("
CALL apoc.load.jdbc('jdbc:oracle:thin:@server',
$Select_In,
[],
{credentials:{user: 'username', password: 'password'}}) YIELD row RETURN row
","
MATCH (co:Comp {id: row.ID}), (co1:Comp {id: row.ID2}
CREATE (co)-[:Relationship]->(co1)
", {batchSize:10000, iterateList:true, parallel:false, 
    params: {Select_In: $Select_In}
   })

Thanks Stefan, that works. I thought i'd tried combinations of that syntax but obviously not!

Hi, I run into problem when setting parameters. It said 'unexpected "\n". What might be the issue? Thank you.