# How to update a procedure previously registered with apoc.custom.asProcedure

**URL:** <https://community.neo4j.com/t/how-to-update-a-procedure-previously-registered-with-apoc-custom-asprocedure/2691>\
**Category:** Procedures & APOC\
**Created:** [October 29, 2018, 8:23am UTC](https://community.neo4j.com/t/how-to-update-a-procedure-previously-registered-with-apoc-custom-asprocedure/2691 "2018-10-29T08:23:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wirselix](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/wirselix/32/947_2.png) [@wirselix](https://community.neo4j.com/u/wirselix)\
**Post date:** [October 29, 2018, 8:23am UTC](https://community.neo4j.com/t/how-to-update-a-procedure-previously-registered-with-apoc-custom-asprocedure/2691/1 "2018-10-29T08:23:02Z")

</div>

Hi apoc community

**Context** :

- neo4j version: 3.4.7 (hosted on [https://app.graphenedb.com/](https://app.graphenedb.com/))
- apoc version: apoc-3.4.0.3-all
- topic is related to apoc.custom.asProcedure

**Problem**  
I am playing around with the new apoc.custom.asProcedure functionality (a big thanks to @stefan.armbruster)  
It works, registering a custom procedures was successful, same for calling the procedure.

First version of the procedure I have registered

```auto
CALL apoc.custom.asProcedure('treeitemlist',
  substring(reduce(s="", x in [
  'MATCH (z:C_tree_item)'
,'WHERE'
,'NOT z:T_tree_item_start'
,'AND z:T_tree_item_end' <-------THIS LINE CONTAINS THE ERROR . should have been: AND NOT z:....
,'WITH z order by z.line_index'
,'WITH collect(z) AS items'
,'RETURN items'
  ] | s+" "+x),1),'read',
  [['items','LIST OF NODE']],[])

```

Unfortunately I made a mistake in my registered cypher statement (see source code above) when calling 'apoc.custom.asProcedure'.  
I tried to fix it by calling again apoc.custom.asProcedure (see source code below), with the same procedure name but updated cypher statement. Still the registered procedure 'treeitemlist' is executed with the wrong cypher statement.

Next try to register procedure 'treeitemlist' with the correct cypher statement

```auto
CALL apoc.custom.asProcedure('treeitemlist',
  substring(reduce(s="", x in [
  'MATCH (z:C_tree_item)'
,'WHERE'
,'NOT z:T_tree_item_start'
,'AND NOT z:T_tree_item_end' <------THIS TIME THE STATEMENT IS CORRECT
,'WITH z order by z.line_index'
,'WITH collect(z) AS items'
,'RETURN items'
  ] | s+" "+x),1),'read',
  [['items','LIST OF NODE']],[])

```

Seems that once a procedure is registered it is imposible to change the cypher statement. Is this correct?  
That raises some more generic questions, but I will create a dedicated topic for them

Best  
Markus

---

<div class="post-metadata">

**Author:** ![Christophe\_Willemsen](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/christophe_willemsen/32/48_2.png) [@Christophe\_Willemsen](https://community.neo4j.com/u/Christophe_Willemsen)\
**Post date:** [October 30, 2018, 10:58am UTC](https://community.neo4j.com/t/how-to-update-a-procedure-previously-registered-with-apoc-custom-asprocedure/2691/2 "2018-10-30T10:58:04Z")

</div>

Can you try to execute the following statement before overriding the custom procedure :

`call dbms.clearQueryCaches()`

---

<div class="post-metadata">

**Author:** ![wirselix](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/wirselix/32/947_2.png) [@wirselix](https://community.neo4j.com/u/wirselix)\
**Post date:** [November 1, 2018, 10:52am UTC](https://community.neo4j.com/t/how-to-update-a-procedure-previously-registered-with-apoc-custom-asprocedure/2691/3 "2018-11-01T10:52:06Z")

</div>

Hi Christophe  
Here is what i tried today:  
1:cleared the query caches as suggested  
2: perform an override of the custom procedure,  
3: call the custom function -\> still old behavior.  
3: Restart DBMS  
4: call the custom function -\> now it works, the custom functions behavior has changed

Probably some caching behavior within the DBMS, that still holds the hold cypher functions for the custom procedure.

And this behavior is reproducible. only after DBMS start the change of the cypher statement in the custom procedure become visible

Best  
Markus
