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.

APOC - jdbcUpdate within periodic.iterate not executing

bieri
Node Link

Hi Everyone

In the last few months, I've created a central database pulling data from several other systems. As a next step it should become a hub for all kinds of dataexchange. I am currently trying to update a MySQL database with the contents of my Neo4j database by combining apoc.periodic.iterate with apoc.load.jdbc and apoc.load.jdbcUpdate. As a first step I only try to update the name column of only a few tuples. The first part of the iterate statement checks which nodes already exist in the MySQL database. The second then should update all existing ones with new names from Neo4j:

CALL apoc.periodic.iterate('
// Check what tuples already exist
WITH \'JDBCConnectString\' AS sql_connect,
\'SELECT prf_addr_nr FROM customer_company WHERE prf_addr_nr != ""\' AS sql_get_customers
CALL apoc.load.jdbc(sql_connect, sql_get_customers) YIELD row RETURN row
','
// Match the existing tuples, with the corresponding nodes in Neo4j
MATCH (cust:Customer) WHERE cust.addressNr = toString(row.prf_addr_nr)
// Build the update SQL-Query
WITH \'JDBCConnectString\' AS sql_connect,
\'UPDATE customer_company SET name = "\' + cust.name + \'" WHERE prf_addr_nr LIKE "%\' + cust.addressNr + \'%";\' AS sql_update_query, cust
// Run the statement
CALL apoc.load.jdbcUpdate(sql_connect, sql_update_query) YIELD row RETURN row

',{batchSize:1000, iterateList: true});

What confuses me is, that the resulting SQL queries are correct (I saved them into the nodes as a means of troubleshooting) and the jdbcUpdate call works as well if run on its own. Even the iterate call runs without errors.

Apoc just seems to ignore any call to apoc.load.jdbcUpdate within apoc.periodic.iterate. Am I right and should I look for another way to solve this or am I doing something wrong?

Thanks in advance for any help
Simon

0 REPLIES 0
Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online