A probable error while using LOAD CSV

I'm running a community edition 4.4.7

I'm importing some data using `LOAD CSV`.

The functions ``linenumber()` and `file()` runs only outside `apoc.do.when` but return `null` if used inside.

The following statement doesn't run:

call apoc.do.when(x IS NULL,
    'MERGE (error:Error)
     MERGE (node)-[h:HAS_ERROR]->(error)
       SET h.linenumber = linenumber(),
           h.file = file()
     RETURN 0',
    'RETURN 1,
    { node:node } YIELD value

While this one runs:

WITH l as linenumber(), f as file()

call apoc.do.when(x IS NULL,
    'MERGE (error:Error)
     MERGE (node)-[h:HAS_ERROR]->(error)
       SET h.linenumber = l,
           h.file = f
     RETURN 0',
    'RETURN 1,
    { l:l, f:f, node:node } YIELD value

I find it a big nuisance!

Can someone confirm and/or explain why? As these two are the only function specific to `LOAD CSV` maybe they could be imported into all the apoc functions!

That make sense to me, as the cypher in the do.when is passed to a custom procedure on the server to run. It does not have access to the scope outside the do.when clause. The ability to pass parameters in the do.when clause is used to pass these values from the outer scope to the custom procedure.

Do you know any way to edit a post after posting in this new version of the community? It look like if you publish, you can never make any correction!

I agree with you: technically it makes sense. But it is an annoying limit.

As we've already seen in another post, apoc will automatically add variables when not explicit declared.
And, as there are only these two functions, apoc could add them to the set of the known values when running a custom procedure. It will allow users to spare a lot of writing!

If you are referring to your prior post, what happened there is the apoc procedure was adding the passed parameters as cypher variables, as well as making them available as parameters. It did not automatically add the outer scope variables to the procedure's scope; you still needed to pass what you wanted as apoc procedure parameters.

I have only got edit to work on my iPhone, not on my Mac laptop. I use Safari on both. Another difference, is the edit on the phone does not have the ellipse option in the icon bar above, so you can select to add code on iPhone, but work on Mac laptop.