1 Reply Latest reply on Apr 10, 2019 6:04 PM by Mike Kutz

    Changing function show effect only after re-connect

    Franck Pachot

      Hi MLE team,

      It seems that if we change the function behaviour (with create or replace) the already connected users do not run the new code until they reconnect.

       

      Here is an example (from this which I wrote for PI-Day: https://medium.com/@FranckPachot/oracle-multi-lingual-engine-7ce6414aa6c4

       

      SQL>  grant dba to demo identified by demo;

       

       

      Grant succeeded.

       

       

      SQL>  connect demo/demo@//localhost/pdb1

      Connected.

      SQL>

      SQL> connect demo/demo@//localhost/pdb1

      Connected.

      SQL> create javascript source named "test1.js" as

        2  module.exports.PI=function (d) {

        3   return Math.round(10**d*Math.PI)/10**d;

        4  }

        5  /

       

       

      Function ( compiled

       

       

      SQL> create function PI(decimals in number)

        2  return number as language javascript

        3  name 'test1\.js.PI(decimals number) return number';

        4  /

       

       

      Function PI compiled

       

       

      SQL> select PI(2) from dual;

       

       

           PI(2)

      ----------

            3.14

       

       

      SQL>

      SQL>

      SQL> create or replace javascript source named "test1.js" as

        2  module.exports.PI=function (d) {

        3   return 1+Math.round(10**d*Math.PI)/10**d;

        4  }

        5  /

       

       

      Function null compiled

       

       

      SQL> create or replace function PI(decimals in number)

        2  return number as language javascript

        3  name 'test1\.js.PI(decimals number) return number';

        4  /

       

       

      Function PI compiled

       

       

      SQL> select PI(2) from dual;

       

       

           PI(2)

      ----------

            3.14

       

       

      SQL> connect demo/demo@//localhost/pdb1

      Connected.

      SQL> select PI(2) from dual;

       

       

           PI(2)

      ----------

            4.14

       

       

      I have changed the code (create or replace javascript source) to add one to the result, and recompiled the function (create or replace function). Next execution has executed the old code. After re-connect I run the new code.

       

      Regards,

      Franck.

       

      Regards,

      Franck.