neo4j 密码:www.example.com中未定义变量apoc.do.case

6yoyoihd  于 2023-01-13  发布在  其他
关注(0)|答案(1)|浏览(139)

我正尝试使用apoc.do.case创建某种关系,具体取决于在阅读CSV后使用WITH是否存在文件中的行
但是,似乎无法将“行”传递到案例中
我的尝试:

LOAD CSV WITH HEADERS FROM 'url' AS row
MERGE (i:Investor {Name: row.Investor_Name})
MERGE (ir:Investment_Round {id: row.Deal_ID})
 WITH row, i, ir
CALL apoc.do.case([
        row.Funds_Used IS NULL,
    'MERGE (i)-[r:INVESTED_IN]->(ir) SET r.Investment_Size_million_GBP=toFloat(row.Investment_Size_million_GBP), r.Investment_Size_million_EUR=toFloat(row.Investment_Size_million_EUR)',
    row.Funds_Used IS NOT NULL, 'MERGE (f:Fund {Name: row.Funds_Used}) WITH row, f, i, ir MERGE (i)-[r:HAS_FUND]->(f) MERGE (f)-[r2:INVESTED_IN]->(ir) SET r2.Investment_Size_million_GBP = row.Investment_Size_million_GBP, r2.Investment_Size_million_EUR = row.Investment_Size_million_EUR;'])
YIELD value RETURN value;

错误:

Failed to invoke procedure `apoc.do.case`: Caused by: org.neo4j.exceptions.SyntaxException: Variable `row` not defined (line 1, column 75 (offset: 74))
"MERGE (i)-[r:INVESTED_IN]->(ir) SET r.Investment_Size_million_GBP=toFloat(row.Investment_Size_million_GBP), r.Investment_Size_million_EUR=toFloat(row.Investment_Size_million_EUR)"
gab6jxml

gab6jxml1#

您没有将row变量作为参数传递。请尝试以下操作:

LOAD CSV WITH HEADERS FROM 'url' AS row
MERGE (i:Investor {Name: row.Investor_Name})
MERGE (ir:Investment_Round {id: row.Deal_ID})
WITH row, i, ir
CALL apoc.do.case([
     row.Funds_Used IS NULL,
    'MERGE (i)-[r:INVESTED_IN]->(ir) 
     SET r.Investment_Size_million_GBP=toFloat(row.Investment_Size_million_GBP), r.Investment_Size_million_EUR=toFloat(row.Investment_Size_million_EUR)',
     row.Funds_Used IS NOT NULL, 
    'MERGE (f:Fund {Name: row.Funds_Used}) WITH row, f, i, ir MERGE (i)-[r:HAS_FUND]->(f) MERGE (f)-[r2:INVESTED_IN]->(ir) SET r2.Investment_Size_million_GBP = row.Investment_Size_million_GBP, r2.Investment_Size_million_EUR = row.Investment_Size_million_EUR;'],
    '', 
    {row: row, i: i, ir: ir}) // The parameters are passed here
YIELD value RETURN value;

相关问题