DBMS_MLE.eval, and finally dropping the context with
DBMS_MLE.drop_context once it is no longer needed. Note that the example encloses the code snippets with
~’ quotes, using PL/SQL’s quote syntax to avoid any escaping issues in code snippets.
console.log() writes to the buffer of the PL/SQL package
DBMS_OUTPUT. If this snippet is executed through a client like SQL Developer Web, SQLcl or SQL*Plus, you’ll see the output generated by
console.log() on the console of those tools. Depending on the client, it might be necessary to enable retrieval of
DBMS_OUTPUT in the client. For example, in SQL*Plus, the printing of the output generated by
DBMS_OUTPUT is controlled by the SET SERVEROUTPUT setting. The output can also be retrieved manually using the
DBMS_MLE is not limited to a single context within a session. Using
54.598000000000006 differs slightly from the actual result of the SQL query due to the floating-point conversion. Although this effect might not seem too relevant in this particular example, this changes drastically once we start dealing with currency values, for example — here, numerical precision is paramount.
To improve on this situation, the
NUMBER column. However, this time we instruct mle-js-oracledb to fetch the column as
OracleNumber objects represent the exact same decimal value as the original SQL value. Furthermore,
OracleNumber objects provide methods for decimal precision arithmetics with the same semantics as the corresponding PL/SQL operations on the NUMBER type.
Multilingual Engine: Embedding GraalVM in the Oracle Database
The following diagram shows a simplified version of MLE’s architecture. Let’s go through some of these boxes and arrows and see what they entail.
Moving further up the stack, let’s discuss the management of MLE contexts that can be created using the
DBMS_MLE API. As described earlier, MLE gives control over context management in a database session to developers, providing a flexible programming model. This is not a special feature of MLE though. The ability to use multiple contexts that encapsulate application and runtime state and are logically independent is built deeply into GraalVM. The GraalVM Polyglot API for embedders supports the creation of multiple independent contexts. MLE’s API for context management is implemented directly on top of the Polyglot API.
Recalling that MLE allows creating several contexts in the same database session, let’s have a look at the following diagram which depicts how the context handles directly map to Polyglot contexts managed in the MLE runtime:
A Vision for the Future
If you want to share with us any feedback about using MLE, or request features for further releases, you can do it here.
Get started with Multilingual Engine for free on Oracle Cloud.