Oracle Database MLE Documentation

This beta release of Oracle Database Multilingual Engine comes as a pre-built VirtualBox appliance or a Docker image. Both run on Oracle Linux 7.2, and have Oracle Database Multiligual Engine pre-installed. The database starts during the boot process of the appliance. The main user of the virutal machine is user oracle (password: oracle).

You can find the v0.2.7 documentation on GitHub.

Below, we provide a glimpse of the workflow by showing how to deploy a JavaScript "Hello World" UDF and invoke it from SQL. 

Implement JavaScript Function

The Oracle Database MLE requires all JavaScript extensions to be implemented as JavaScript modules, following practice that is common to JavaScript developers. Oracle Database MLE supports modules written as UMD modules. It is the most common pattern for writing modules and can be generated by a variety of tools (like, e.g., browserify). However, the simplest way to write a module that can be loaded by Oracle Database MLE is to use Common-JS and to specify the functions that should be callable from the Oracle Database as properties of ``module.exports`` as illustrated here:

module.exports.helloworld = function () { return "Hello World"; }

We save this file as helloworld.js.

Declare Signature Using TypeScript

The next step is to provide a type declaration for all exported functions. Since we only export one function in our example, we provide a specification for the input and output types of helloworld. This specification is written as a TypeScript declaration file and states that the function has no inputs and produces a string as output.

export function helloworld() : string;

We save this file as helloworld.d.ts.

Deploy into Database

The specification is needed to bridge the gap between the statically-typed SQL world of the database and the dynamically typed JavaScript world. With an implementation and a type specification we can then use the deployment tool dbjs to deploy the script into the database.

shell> dbjs deploy helloworld.js -u myuser -p mypasswd -c mydb:1521/globaldbname

Invoke UDF from SQL

To use this script, we connect to the database with our favorite DB connector (e.g., SQL*Plus) and use a query that calls the function helloworld.

sql> select helloworld() from dual;
Oracle Live SQL

OTN Cloud Promo RHS