cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site migration is underway. Phase 2: migrate recent content

Call apoc procedure in subquery

martin2
Node Link

I am trying to set labels dynamically with the `poc.create.setLabels function:

:auto MATCH (n:TempNode)
CALL {
    with n
    CALL apoc.create.setLabels( n, [ n.type ] ) YIELD node
} IN TRANSACTIONS;

I get a strange error that I never saw before:

Neo.ClientError.Statement.SyntaxError

Variable `n` not defined (line 3, column 10 (offset: 35))
"    with n"
          ^

Any ideas why this fairly simple query does not work?

2 REPLIES 2

bennu_neo
Neo4j
Neo4j

Hi @martin2 !

Really interesting. This is mainly due to the parsing expecting a node Yield call function. I'll check this internally, meanwhile, considering you are changing into a label, removing also the type will make it work.

:auto MATCH (n:TempNode)
CALL {
    with n
    CALL apoc.create.setLabels( n, [ n.type ] ) YIELD node
    remove n.type
} IN TRANSACTIONS;
Oh, y’all wanted a twist, ey?

glilienfield
Ninja
Ninja

Try this:

:auto 
MATCH (n:TempNode)
CALL {
    with n
    CALL apoc.create.setLabels( n, [ n.type ] ) yield node
    return node
} IN TRANSACTIONS
return node

It didn't seem to like the yield without a return.