Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-17-2020 07:34 AM
I am trying to check if a user has already created a particular node. If the user has already created it I want to return the duplicate number and if user hasnt, create the node. Using the query below:
UNWIND $testdata as row
OPTIONAL MATCH (a:Agency)
WHERE a.agency_name = row.agency_name
WITH count(a.agency_name) as cp,row
CALL apoc.do.when(
sum(cp)=0,
'MERGE (a:Agency {_uuid:apoc.create.uuid()})
ON CREATE SET a+= row
RETURN a AS data',
'RETURN sum(cp) AS NumDuplicate',
{row:row,cp:cp}) YIELD value
RETURN value
However I receive an error: Procedure call cannot take an aggregating function as argument, please add a 'WITH' to your statement. I don't understand why I receive this error when I already have a WITH clause above the CALL clause.
Solved! Go to Solution.
06-17-2020 07:59 AM
Hello @tarendran.vivekanand
Replace sum(cp)=0,
by cp=0,
Or if you want to do the SUM()
of cp
, you must do it in a WITH
clause before the CALL
.
Regards,
Cobra
06-17-2020 07:59 AM
Hello @tarendran.vivekanand
Replace sum(cp)=0,
by cp=0,
Or if you want to do the SUM()
of cp
, you must do it in a WITH
clause before the CALL
.
Regards,
Cobra
All the sessions of the conference are now available online