# Disruptive error: the \`USE\` command doesn't run correctly

**URL:** <https://community.neo4j.com/t/disruptive-error-the-use-command-doesnt-run-correctly/72959>\
**Category:** Cypher\
**Tags:** browser, operations, neo4j-desktop\
**Created:** [March 11, 2025, 10:06am UTC](https://community.neo4j.com/t/disruptive-error-the-use-command-doesnt-run-correctly/72959 "2025-03-11T10:06:38Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![paolodipietro58](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/paolodipietro58/32/21045_2.png) [@paolodipietro58](https://community.neo4j.com/u/paolodipietro58)\
**Post date:** [March 11, 2025, 10:06am UTC](https://community.neo4j.com/t/disruptive-error-the-use-command-doesnt-run-correctly/72959/1 "2025-03-11T10:06:38Z")

</div>

I'm running neo4j enterprise server 5.26.1 with browser 5.26.2

I have two graphs: one named `neo4j` and the other named `gdpr`.

In the browser, I'm positioned on the `Neo4j` Database.

When I run the following query

 ![Screenshot 2025-03-11 alle 11.01.24](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/5/e/5e3cf7b2d7352e437802847ed50898b0a878764a.png)

the result seems `0` as expected, but it is on the wrong DB: it emptyed the Neo4j DB and not the gdpr DB as you could see in the following image:

 ![Screenshot 2025-03-11 alle 11.04.20](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/a/d/ade3bd0dda10e5ce1ff3fae04630031de4753228.png)

So, it is my fault or the neo4j one?

---

<div class="post-metadata">

**Author:** ![joshcornejo](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/joshcornejo/32/34171_2.png) [@joshcornejo](https://community.neo4j.com/u/joshcornejo)\
**Post date:** [March 11, 2025, 11:44am UTC](https://community.neo4j.com/t/disruptive-error-the-use-command-doesnt-run-correctly/72959/2 "2025-03-11T11:44:23Z")

</div>

From your other thread, have you tried:

```auto
call {
    use gdpr
    
   ... CYPHER ...
}
```

---

<div class="post-metadata">

**Author:** ![paolodipietro58](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/paolodipietro58/32/21045_2.png) [@paolodipietro58](https://community.neo4j.com/u/paolodipietro58)\
**Post date:** [March 11, 2025, 1:26pm UTC](https://community.neo4j.com/t/disruptive-error-the-use-command-doesnt-run-correctly/72959/3 "2025-03-11T13:26:47Z")

</div>

I tryed the following:

 ![Screenshot 2025-03-11 alle 14.20.29](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/8/6/8603ee6db5da3f4022b0d15e72882d734e1f2c4e.png)

AS my gdpr DB is also part of a composite database, I tried with the composite db also, but the result was not correct:

 ![Screenshot 2025-03-11 alle 14.25.04](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/6/0/60cf34bc6c8cadb9cfe35842766563a4c166e153.png)

and the `gdpr` DB is always full of nodes as you can see

 ![Screenshot 2025-03-11 alle 14.25.59](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/d/b/db524b585229ad2311ef407623168fa25a6011ef.png)

---

<div class="post-metadata">

**Author:** ![glilienfield](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/glilienfield/32/27534_2.png) [@glilienfield](https://community.neo4j.com/u/glilienfield)\
**Post date:** [March 12, 2025, 2:24am UTC](https://community.neo4j.com/t/disruptive-error-the-use-command-doesnt-run-correctly/72959/4 "2025-03-12T02:24:22Z")

</div>

Are you using the dropdown list to select the database, then executing the query in the resulting editor that shows the database name as the prompt? Your results can be explained if you ran the query in the editor that is set to use the wrong database.

---

<div class="post-metadata">

**Author:** ![paolodipietro58](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/paolodipietro58/32/21045_2.png) [@paolodipietro58](https://community.neo4j.com/u/paolodipietro58)\
**Post date:** [March 12, 2025, 9:04am UTC](https://community.neo4j.com/t/disruptive-error-the-use-command-doesnt-run-correctly/72959/5 "2025-03-12T09:04:11Z")

</div>

So, the basic question is:

`Can I programmatically change the master database where I'm running?`

Without being constrained to choose it in the dropdown list?

At me, this situation looks like the `composite database` is not mature enough and can easily bring to disaster in the other databases!

---

<div class="post-metadata">

**Author:** ![glilienfield](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/glilienfield/32/27534_2.png) [@glilienfield](https://community.neo4j.com/u/glilienfield)\
**Post date:** [March 12, 2025, 12:15pm UTC](https://community.neo4j.com/t/disruptive-error-the-use-command-doesnt-run-correctly/72959/6 "2025-03-12T12:15:33Z")

</div>

The dropdown list is just a simple means of executing the ':USE ' command, instead of manually typing it. You need to make sure you run your query in the new editor that is created that has the prompt with the database name in it. All previous editors don't change, so you cannot just go rerun those assuming they will use the new database.

I think this is an issue when using the browser. It seems you can't start the query with a "USE " to switch to the composite database, then run a query with multiple databases, as it thinks you are running the database in the one identified in the prompt. In the browser, you need to switch the editor to the composite database, then run the query in that editor. I don't think this is an issue when using a driver, as you can create a session and specify to use the composite database in the session configuration. You can then run your query utilizing database's that are part of the composite database. I have not tried this though.

---

<div class="post-metadata">

**Author:** ![glilienfield](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/glilienfield/32/27534_2.png) [@glilienfield](https://community.neo4j.com/u/glilienfield)\
**Post date:** [March 12, 2025, 12:20pm UTC](https://community.neo4j.com/t/disruptive-error-the-use-command-doesnt-run-correctly/72959/7 "2025-03-12T12:20:57Z")

</div>

BTW- it does seem that the 'USE database' at the start of your query does not switch the database, so you query still runs agains the database identified in the editor's prompt. This would explain why you deleted the nodes in the wrong database. I was able to reproduce this.

I agree that this seems unintuitive and dangerous.

---

<div class="post-metadata">

**Author:** ![glilienfield](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/glilienfield/32/27534_2.png) [@glilienfield](https://community.neo4j.com/u/glilienfield)\
**Post date:** [March 12, 2025, 12:27pm UTC](https://community.neo4j.com/t/disruptive-error-the-use-command-doesnt-run-correctly/72959/8 "2025-03-12T12:27:55Z")

</div>

Now I am confused. I tried it again and now it is working as you would expect. I am not sure what changed. In the simulation, I created some nodes in db1 and ran the query in a db1 editor that started with USE db2, then deleted nodes. Initially this was deleting the nodes in db1 when the editor prompt was db1, but now it is not.

```auto
USE db2
match(n) delete n

```

 ![Screenshot 2025-03-12 at 8.28.40 AM](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/0/3/03935d9e952b7ce8bf473f124d6cf11eda04bf3f.png)

 ![Screenshot 2025-03-12 at 8.28.49 AM](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/9/f/9f2eb6e48519bff1e95dc0277a74ab4d3aac6111.png)

---

<div class="post-metadata">

**Author:** ![paolodipietro58](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/paolodipietro58/32/21045_2.png) [@paolodipietro58](https://community.neo4j.com/u/paolodipietro58)\
**Post date:** [March 12, 2025, 6:57pm UTC](https://community.neo4j.com/t/disruptive-error-the-use-command-doesnt-run-correctly/72959/9 "2025-03-12T18:57:27Z")

</div>

This (obviously) run, because I don't pass nodes to a call and not use `WITH x AS y`:

 ![Screenshot 2025-03-12 alle 19.36.25](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/6/4/641d85b1a8409eca9083b655e49fe59eb8084cc2.png)

but the manual asserts that `Updates can only be performed on a single constituent graph per transaction`.

How can we ask `Neo4j developers` on how to implement the above assertion and make an update in just one designed database?

---

<div class="post-metadata">

**Author:** ![paolodipietro58](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/paolodipietro58/32/21045_2.png) [@paolodipietro58](https://community.neo4j.com/u/paolodipietro58)\
**Post date:** [March 12, 2025, 8:25pm UTC](https://community.neo4j.com/t/disruptive-error-the-use-command-doesnt-run-correctly/72959/10 "2025-03-12T20:25:51Z")

</div>

And this is another crazy example: can someone tell me how to use federateddatabases in neo4j???

 ![Screenshot 2025-03-12 alle 21.24.31](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/2/d/2dced3df746f8ecfe6a990f3396a1306b2ace281.png)

I reach the following conclusion: federatedDBs cannot be used safely with Cypher but only with external drivers.

This is not a good signal from neo4j developers.

---

<div class="post-metadata">

**Author:** ![glilienfield](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/glilienfield/32/27534_2.png) [@glilienfield](https://community.neo4j.com/u/glilienfield)\
**Post date:** [March 13, 2025, 12:17am UTC](https://community.neo4j.com/t/disruptive-error-the-use-command-doesnt-run-correctly/72959/11 "2025-03-13T00:17:12Z")

</div>

You can't import the node 'n' to the second subquery that uses a different database. It wouldn't be useful in a query on another database, as the node that the variable would be bound to can't be accessed by the other database. The way to handle this is to pass specific information about the node that you can use in the second subquery, such as the node's label and/or properties.

Try something like this:

 ![Screenshot 2025-03-12 at 8.13.12 PM](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/1/7/1755e1d0677c45ab043061b15813455fbef8cdca.png)

In the example you are showing, the second 'call' is nested within the first subquery. This is not allowed, since the outer query specifies the database. All following queries must use the same database as the outermost query.

---

<div class="post-metadata">

**Author:** ![paolodipietro58](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/paolodipietro58/32/21045_2.png) [@paolodipietro58](https://community.neo4j.com/u/paolodipietro58)\
**Post date:** [March 13, 2025, 6:36am UTC](https://community.neo4j.com/t/disruptive-error-the-use-command-doesnt-run-correctly/72959/12 "2025-03-13T06:36:59Z")

</div>

some things, only somehow, look reasonable.

But my Use Case is the following:

`I have a GDPR database containing all the reserved data for a User|Customer. I want to access that DB and return a vnode, containing just the uuid and the nickaname of the subject. Then I want to save these 2 data in the other DB to be used later`

I'm convinced that it can be only obtained using an external piece of code (python, node?) and save these info in a session block.

The second thing:

I want to read from the first db and later write other things to a second: how can I accomplish that if I cannot change my db? How can i designate the only write DB?

Maybe with a call IN TRANSACTION?

---

<div class="post-metadata">

**Author:** ![glilienfield](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/glilienfield/32/27534_2.png) [@glilienfield](https://community.neo4j.com/u/glilienfield)\
**Post date:** [March 13, 2025, 1:57pm UTC](https://community.neo4j.com/t/disruptive-error-the-use-command-doesnt-run-correctly/72959/13 "2025-03-13T13:57:11Z")

</div>

I think this mimics your use case.

```auto
call {
    use comp.alias_db1
    match(n:Customer)
    return n.uuid as uuid, n.nickname as nickname
}
call {
    use comp.alias_db2
    with uuid, nickname
    create(m:Customer{uuid: uuid, nickname: nickname})
    return m
}
return m

```

In the following, there are two Customer nodes in the db1 database and zero Customer nodes in the db2 database. The query retrieves the two Customer nodes for db1 and creates nodes in db2 using the node's UUID and nickname properties.

 ![Screenshot 2025-03-13 at 9.52.54 AM](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/6/1/6138d228ce5ec37868a73f73d5ac5b960ceea96f.png)

 ![Screenshot 2025-03-13 at 9.53.39 AM](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/0/d/0d462caa6ec19f8fe7c911fa291908a5dbe309b3.png)

 ![Screenshot 2025-03-13 at 9.54.06 AM](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/5/1/5178df02ae978148f9a9abb4a749eaa4fd1c816c.png)

 ![Screenshot 2025-03-13 at 9.54.21 AM](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/2/d/2d541c3523d41238fb24522d092f445e15741629.png)

---

<div class="post-metadata">

**Author:** ![paolodipietro58](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/paolodipietro58/32/21045_2.png) [@paolodipietro58](https://community.neo4j.com/u/paolodipietro58)\
**Post date:** [March 13, 2025, 6:12pm UTC](https://community.neo4j.com/t/disruptive-error-the-use-command-doesnt-run-correctly/72959/14 "2025-03-13T18:12:36Z")

</div>

Well, this looks to tun correctly.

But now, how can we push ahead another little step?

In the step 1 you read just one exact node from the DB1.

what if you want to retrieve all customers, or all nodes which correspond to certain characteristics at all? (example: all nodes with a specific attribute, or in relation with another specific node like MATCH (m)-[r:BELONGS\_TO]-\>(x:Customer). )

and the replicate them in the second db .... how to pass labels(m) and properties(m) to the second query?

This is exactly my goal

---

<div class="post-metadata">

**Author:** ![glilienfield](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/glilienfield/32/27534_2.png) [@glilienfield](https://community.neo4j.com/u/glilienfield)\
**Post date:** [March 13, 2025, 7:35pm UTC](https://community.neo4j.com/t/disruptive-error-the-use-command-doesnt-run-correctly/72959/15 "2025-03-13T19:35:15Z")

</div>

Using this test data:

```auto
create(n:Customer{id:0, nickname: "minnie"})
create(n)<-[:BELONGS_TO]-(:Item{name:"bike"})
create(n)<-[:BELONGS_TO]-(:Item{name:"glove"})
create(n)<-[:BELONGS_TO]-(:Item{name:"hat"})
create(m:Customer{id:1 nickname: "mickey"})
create(m)<-[:BELONGS_TO]-(:Item{name:"jacket"})
create(m)<-[:BELONGS_TO]-(:Item{name:"coat"})

```

Initial state of db1:

 ![Screenshot 2025-03-13 at 3.31.20 PM](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/6/a/6a6fcdf426815e26d7ec182acb7cb65e084f335e.png)

Initial state of db2:

 ![Screenshot 2025-03-13 at 3.24.59 PM](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/f/4/f4a559312da1e5e221c1cbadeac5fd7da14c12f4.png)

Query:

```auto
call {
    use comp.alias_db1
    match(n)<-[:BELONGS_TO]-(m)
    return 
        properties(n) as properties_n, labels(n) as labels_n,
        properties(m) as properties_m, labels(m) as labels_m
}
call {
    use comp.alias_db2
    with properties_n, labels_n, properties_m, labels_m
    merge(x:$(labels_n){id: properties_n.id})
    merge(y:$(labels_m){name: properties_m.name})
    merge(x)<-[:BELONGS_TO]-(y)
}

```

Query execution in composite db:

 ![Screenshot 2025-03-13 at 3.33.48 PM](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/b/d/bd3f413c25ed43d6cb71bc30aa5cea780c1e20a9.png)

db2 state after executing 'copy' query in composite database:

 ![Screenshot 2025-03-13 at 3.34.14 PM](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/b/c/bc71a57e7111a899ba97266fc663e64e3a7b7431.png)

Does this meet your needs? Note, I could have not specified the relationship type and passed it through to the second call subquery to create the relationship with the correct type.

---

<div class="post-metadata">

**Author:** ![paolodipietro58](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/paolodipietro58/32/21045_2.png) [@paolodipietro58](https://community.neo4j.com/u/paolodipietro58)\
**Post date:** [March 13, 2025, 8:33pm UTC](https://community.neo4j.com/t/disruptive-error-the-use-command-doesnt-run-correctly/72959/16 "2025-03-13T20:33:24Z")

</div>

hmm, it is a step ahead,

next step (maybe the latest: how to copy all the properties of `properties_n` and `properties_m` (i don't know which are the properties of any node! as `id` or `name`.

---

<div class="post-metadata">

**Author:** ![glilienfield](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/glilienfield/32/27534_2.png) [@glilienfield](https://community.neo4j.com/u/glilienfield)\
**Post date:** [March 13, 2025, 9:14pm UTC](https://community.neo4j.com/t/disruptive-error-the-use-command-doesnt-run-correctly/72959/17 "2025-03-13T21:14:58Z")

</div>

You can set all the properties with the following:

```auto
Set x = properties_n
Set y = properties_m

```

But you will need primary keys to drive the merges.

---

<div class="post-metadata">

**Author:** ![paolodipietro58](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/paolodipietro58/32/21045_2.png) [@paolodipietro58](https://community.neo4j.com/u/paolodipietro58)\
**Post date:** [March 14, 2025, 8:25am UTC](https://community.neo4j.com/t/disruptive-error-the-use-command-doesnt-run-correctly/72959/18 "2025-03-14T08:25:18Z")

</div>

Hi Gary, this is the solution I needed.

The primary key is already settled, because for each different nodes the constraint will be declared in both the DB, I just don't know which kind of node I'll managing at every call.

Well, thank you, as always you find the right solution.

At the next one!

---

<div class="post-metadata">

**Author:** ![paolodipietro58](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/paolodipietro58/32/21045_2.png) [@paolodipietro58](https://community.neo4j.com/u/paolodipietro58)\
**Post date:** [March 14, 2025, 10:01pm UTC](https://community.neo4j.com/t/disruptive-error-the-use-command-doesnt-run-correctly/72959/19 "2025-03-14T22:01:00Z")

</div>

@glilienfield , this example is with DB 5.27.0 Enterprise

I was so happy with the solution, but there is something already not running as (I) expected !

I have this `gdpr` graph, which is part of the `federatednotions` one.

this is a direct query result:

 ![Screenshot 2025-03-14 alle 22.48.20](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/8/6/8697529602f7f4f9aeb63aa2d4b306377bb5d381.png)

as you can see, there are exactly 18 nodes into the gdpr graph.

Now, I run this query with the idea to empty my gdpr database:

 ![Screenshot 2025-03-14 alle 22.56.23](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/9/4/9458528144de4e212aafe2603d9358cd114d6040.png)

The result is that nothing seems to happen, and if I query again the `federatednotions.gdpr`, it results. with all the nodes, as at the beginning.

 ![Screenshot 2025-03-14 alle 23.00.16](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/8/f/8f6a9c2949ce9d081564eb333050f27f15515cd5.jpeg)

As the manual states 'you can use just `one graph in a write query`, I just used only the `federatednotions.gdpr`

Can you see something wrong? Where is the error?

---

<div class="post-metadata">

**Author:** ![glilienfield](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/glilienfield/32/27534_2.png) [@glilienfield](https://community.neo4j.com/u/glilienfield)\
**Post date:** [March 15, 2025, 12:39am UTC](https://community.neo4j.com/t/disruptive-error-the-use-command-doesnt-run-correctly/72959/20 "2025-03-15T00:39:20Z")

</div>

The result of your first query is showing only nodes, no relationships. Unless you have the default behavior turned off (default is to "connect result nodes"), I am deducing you don't have any relationships. Oh, I just saw in the left-hand pane it states "no relationships in the database", so I was correct. Because of this, your `match (n)-[r]-(m)` returned zero results, thus the query stopped.

 ![Screenshot 2025-03-14 at 8.17.35 PM](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/b/2/b20e0497e2f4bcdd60836cee32724d96ce4f8c5a.png)

Just a note, you don't need to use the composite database if you are not querying for data in more than one database. In your case as presented, you can execute the deleting in the 'gdpr' database directly (well, the database that is aliased by 'federatednotions.gdpr'.

You can use two techniques to delete all nodes/relationships in a graph. One is to create/replace the graph or match all nodes and detach delete them.

Execute either of the two in the gdpr database:

```auto
create or replace database gdpr

```

```auto
match(n) detach delete n

```

[Next page](https://community.neo4j.com/t/disruptive-error-the-use-command-doesnt-run-correctly/72959.md?page=2)
