Call apoc.periodic.iterate could not run with call apoc.cypher.run


I want to execute this query but when I add call apoc.cypher.run I got an statement syntax error
It could not read the merge on the apoc.cypher.run clause. It gives me invalid input
could some one verify the syntax for me please
thank you

It looks like you are mixing/switching between single and double quotes, so it is not parsed correctly. Pick either single or double quotes to delimit the strings used to define the string parameters, when use the other quotes within the strings if needed.

I rectify the request by modifying the quotes. When I put the relationship type "est_actionnaire_de" it executes correctly but when I put '+ro.desc_rela_desc+' which is the column name returned by my sql query it gives me an errer saying that variable ro not defined. despite I already used it for the origin and destination node definition. Why it does not accept '+ro.desc_rela_desc+'


could you please help me

Can you paste code, so I don't have to create it. I can edit it.

1 Like

BBCode
call apoc.periodic.iterate(
'
call apoc.load.jdbc(" "," select ....") yield row',
'call apoc.cypher.run("merge(orig:D2_V_NOEUD_PARTI{ID:row.ORIGIN})-[r: '+row.DESC_RELA_DESC+'{DAT_DEB:ro.DAT_DEB,dat_fin:row.DAT_FIN}]->(dest:D2_NOEUD_ENTRPR{ID:row.DESTINATION}) RETURN r",{row:row}) yield value
with value,row
call apoc.create.setRelProperty(value.r,"POURCENTAGE",row.VAL_PROP) yield rel return rel',{batchSize:1000,parallel:false})


I replaced ro by row and I modified the request as in the code below but I got variable row not defined

Try this:

call apoc.periodic.iterate(
'
call apoc.load.jdbc(" "," select ....") yield row
',
'
call apoc.cypher.run("merge(orig:D2_V_NOEUD_PARTI{ID:row.ORIGIN})-[r: “+row.DESC_RELA_DESC+”{DAT_DEB:ro.DAT_DEB,dat_fin:row.DAT_FIN}]->(dest:D2_NOEUD_ENTRPR{ID:row.DESTINATION}) RETURN r”
,{row:row}) yield value
with value,row
call apoc.create.setRelProperty(value.r,"POURCENTAGE",row.VAL_PROP) yield rel 
return rel
'
,{batchSize:1000,parallel:false})

I think you could simplify the query using apoc.merge.relationship. It could replace both apoc calls, since you can set relationship properties

1 Like

Thank you for your response. Just one other question please could I use call apoc procedures with neo4j community 5.1 version please?

Yes. Enterprise has addition features not available in community, such as clustering, multiple databases, security, etc. Plug-ins should work in either version.