Changing function show effect only after re-connect — oracle-tech

    Forum Stats

  • 3,715,723 Users
  • 2,242,844 Discussions
  • 7,845,508 Comments

Discussions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Changing function show effect only after re-connect

Franck Pachot
Franck Pachot Member Posts: 912 Bronze Trophy
edited April 2019 in Multilingual Engine

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/[email protected]//localhost/pdb1

Connected.

SQL>

SQL> connect demo/[email protected]//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/[email protected]//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.

Answers

Sign In or Register to comment.