Oracle Database MLE以VirtualBox映像的形式提供。该映像包含Oracle Database MLE、文档和教程。还包括一个部署工具 (dbjs),可用于将JavaScript 模块部署到数据库中。数据库可以将这些模块导出的函数作为存储过程或用户定义的函数进行调用。虚拟机下载地址
http://www.oracle.com/technetwork/database/multilingual-engine/downloads/index.html
[oracle@dbml ~]$ sqlplus / as sysdba
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0_MLE - 64bit Beta
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> select name from v$database;
NAME
---------
DBML
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0_MLE - 64bit Beta
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
[oracle@dbml ~]$
部署工具dbjs
[oracle@dbml ~]$ which dbjs /usr/local/bin/dbjs [oracle@dbml ~]$ ls -l /usr/local/bin/dbjs lrwxrwxrwx. 1 root root 34 Sep 29 2017 /usr/local/bin/dbjs -> ../lib/node_modules/dbjs/bin/db.js [oracle@dbml ~]$ ls -l /usr/local/lib/node_modules/dbjs/bin/db.js -rwxrwxrwx. 1 root root 7315 Sep 29 2017 /usr/local/lib/node_modules/dbjs/bin/db.js [oracle@dbml ~]$Oracle Database MLE要求所有JavaScript扩展作为JavaScript模块实现,这是JavaScript开发人员的通常做法。Oracle Database MLE支持以UMD 模块形式编写的模块。这是很常见的模块编写模式,可以通过各种工具(如 browserify)生成。但是,编写可以由Oracle Database MLE加载的模块的最简单的方法是使用Common-JS,并将可从Oracle 数据库调用的函数指定为“module.exports”的属性,下面是示例:
1.编写JavaScript,并保存为helloworld.js
module.exports.helloworld = function () { return "Hello World"; }2.编写TypeScript声明文件,并保存为helloworld.d.ts
export function helloworld() : string;3.部署到数据库
dbjs deploy helloworld.js -u scott -p tiger -c localhost:1521/DBML
[oracle@dbml ~]$ dbjs deploy -vv helloworld.js -u scott -p tiger -c localhost:1521/DBML deploy: command called /home/oracle/helloworld.js oracle Oracle backend: starting transpiler helloworld: processed function Oracle backend: opening connection to database loadModule: called with helloworld.js BEGIN EXECUTE IMMEDIATE 'CREATE PACKAGE HELLOWORLD AS FUNCTION HELLOWORLD RETURN VARCHAR2 AS LANGUAGE JS LIBRARY "helloworld.js" NAME "helloworld" ; END HELLOWORLD;'; END; : generated PLSQL + helloworld.js └─┬ helloworld └── SCALAR FUNCTION HELLOWORLD.HELLOWORLD RETURN VARCHAR2 [oracle@dbml ~]$4.从SQL调用UDF
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0_MLE - 64bit Beta With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options SQL> select helloworld() from dual; HELLOWORLD() -------------------------------------------------------------------------------- Hello World SQL>
下面这篇文章测试更有说服力
http://blog.dbi-services.com/oracle-database-multilingual-engine-mle/
http://www.oracle.com/technetwork/database/multilingual-engine/overview/index.html
http://www.oracle.com/technetwork/cn/database/multilingual-engine/overview/index.html
http://www.oracle.com/technetwork/cn/database/multilingual-engine/documentation/index.html
http://pages.pacificcoast.net/~cazelais/euclid.html
http://blog.dbi-services.com/oracle-database-multilingual-engine-mle/
https://oracle.github.io/oracle-db-mle/releases/0.2.7/
https://oracle.github.io/oracle-db-mle/vbox/