|
1 | 1 | # MLE Modules |
2 | | -This repository contains documentation and interface definitions for MLE modules as provided in Oracle Database. |
| 2 | +The Oracle Database Multilingual Engine (MLE) enables [JavaScript execution in Oracle Database as of version 21c][1]. |
| 3 | +In this database JavaScript environment, there exist some JavaScript modules that are available out of the box. |
| 4 | +This repository contains documentation and interface definitions (in the form of TypeScript declarations) for those pre-defined modules. |
| 5 | +While the documentation contains set of human-readable, linked pages, the TypeScript declaration files are typically consumed by an IDE for improving auto-completion. |
| 6 | +This is particularly useful in a scenario where JavaScript code gets developed locally in an IDE and then deployed to the database. |
3 | 7 |
|
4 | | -## Oracle Database 21c |
| 8 | +The following JavaScript modules are currently available: |
| 9 | +- MLE SQL Driver: [mle-js-oracledb][mle-js-oracledb] |
| 10 | +- MLE Bindings: [mle-js-bindings][mle-js-bindings] |
| 11 | +- MLE PL/SQL Types [mle-js-plsqltypes][mle-js-plsqltypes] |
5 | 12 |
|
6 | | -### Interface Definitions |
7 | | -- MLE SQL Driver: [./mle-js-oracledb](./mle-js-oracledb) |
8 | | -- MLE Bindings: [./mle-js-bindings](./mle-js-bindings) |
9 | | -- MLE PL/SQL Types [./mle-js-plsqltypes](./mle-js-plsqltypes) |
| 13 | +## Installation |
| 14 | +You need an Oracle Database to make use of the JavaScript modules provided in the Oracle Database Multilingual Engine (MLE). |
| 15 | +A very convenient way of getting an Oracle Database instance is to create an always-free Oracle Cloud account and set up a free autonomous database instance there as our [blog article][2] explains in great detail. |
10 | 16 |
|
11 | | -### Documentation |
12 | | -- MLE SQL Driver: [./docs/mle-js-oracledb/21.3.0](./docs/mle-js-oracledb/21.3.0) |
13 | | -- MLE Bindings: [./docs/mle-js-bindings/21.3.0](./docs/mle-js-bindings/21.3.0) |
14 | | -- MLE PL/SQL Types [./docs/mle-js-plsqltypes/21.3.0](./docs/mle-js-plsqltypes/21.3.0) |
| 17 | +The declaration files can conveniently be installed into your project directory using NPM: |
15 | 18 |
|
| 19 | +``` |
| 20 | +npm install mle-js-oracledb |
| 21 | +npm install mle-js-bindings |
| 22 | +npm install mle-js-plsqltypes |
| 23 | +``` |
| 24 | + |
| 25 | +## Documentation |
| 26 | + |
| 27 | +### MLE SQL Driver (mle-js-oracledb) |
| 28 | +If JavaScript is executed inside the database, SQL statements can be executed using an easy to use SQL driver. |
| 29 | +This driver is built-in into the JavaScript engine in the database. |
| 30 | + |
| 31 | +[Continue reading...][mle-js-oracledb] |
| 32 | + |
| 33 | +### MLE Bindings for Oracle Database `DBMS_MLE` (mle-js-bindings) |
| 34 | +The MLE Bindings module can be used to exchange values between PL/SQL and JavaScript. |
| 35 | +The module also takes care of converting values from PL/SQL types to JavaScript types and vice-versa automatically as required. |
| 36 | + |
| 37 | +[Continue reading...][mle-js-bindings] |
| 38 | + |
| 39 | +### MLE PL/SQL Types (mle-js-plsqltypes) |
| 40 | +MLE allows importing SQL values from PL/SQL as well as fetching them from a SQL statement. |
| 41 | +By default, SQL values get converted to JavaScript values during that process, e.g. an Oracle `NUMBER` gets converted to a JavaScript `number`. |
| 42 | +Sometimes it is required to have JavaScript values that behave exactly as if they were SQL values. |
| 43 | +The mle-js-plsqltypes module contains JavaScript APIs for such JavaScript objects that wrap PL/SQL objects. |
| 44 | + |
| 45 | +[Continue reading...][mle-js-plsqltypes] |
| 46 | + |
| 47 | +### Oracle Database |
| 48 | +Oracle Database is the world's most popular database. |
| 49 | +Available on cloud and on-premises platforms, Oracle Database 19c is the most recent long term release, with an extended support window. |
| 50 | +Oracle Database 21c is the latest innovation release, initially available on Oracle cloud through Autonomous Database Free Tier and Database Cloud Service. |
| 51 | + |
| 52 | +[Continue reading...][3] |
| 53 | + |
| 54 | +### Version Mapping |
| 55 | +The following table shows which version of module documentation and declarations work with which version of Oracle Database: |
| 56 | + |
| 57 | +| Oracle Database | Modules | |
| 58 | +| ---------------- | --------| |
| 59 | +| 21.3, 21.4, etc. | [[email protected]][mle-js-oracledb] < br/> [[email protected]][mle-js-bindings] < br/> [[email protected]][mle-js-plsqltypes] | |
| 60 | + |
| 61 | +## Examples |
| 62 | +The following code snippet exemplifies the usage of all MLE modules combined. |
| 63 | +For additional examples, please check the module documentation pages or have a look at our [blog article][2]. |
| 64 | + |
| 65 | +```JavaScript |
| 66 | +// imports |
| 67 | +const oracledb = require('mle-js-oracledb'); |
| 68 | +const bindings = require('mle-js-bindings'); |
| 69 | +const plsqltypes = require("mle-js-plsqltypes"); |
| 70 | + |
| 71 | +// Read a large number as an Oracle NUMBER from SQL and add another ORACLE NUMBER to it. |
| 72 | +// mle-js-oracledb is used for reading from SQL and mle-js-plsqltypes is used to construct the second Oracle NUMBER. |
| 73 | +const conn = oracledb.defaultConnection(); |
| 74 | +const query = "SELECT 9007199254740992 AS n FROM dual"; |
| 75 | +const options = { fetchInfo: { N: { type: oracledb.ORACLE_NUMBER } } }; |
| 76 | +const queryResult = conn.execute(query, [], options); |
| 77 | +const OracleNumber = plsqltypes.OracleNumber; |
| 78 | +const result = queryResult.rows[0][0].add(new OracleNumber(7)); |
| 79 | + |
| 80 | +// Use mle-js-bindings to export the result of the computation. |
| 81 | +// On the database side, this result could be retrieved using something like `dbms_mle.import_from_mle(ctx, 'result', result);`. |
| 82 | +bindings.exportValue("result", result); |
| 83 | +``` |
| 84 | + |
| 85 | +## Help |
| 86 | +If you have questions or change requests about MLE, please [create a ticket](./CONTRIBUTING.md) or contact [Oracle Support](https://support.oracle.com). |
| 87 | + |
| 88 | +## Contributing |
| 89 | +This project welcomes contributions from the community. |
| 90 | +Before submitting a pull request, please [review our contribution guide](./CONTRIBUTING.md). |
| 91 | + |
| 92 | +## Security |
| 93 | + |
| 94 | +Please consult the [security guide](./SECURITY.md) for our responsible security vulnerability disclosure process. |
| 95 | + |
| 96 | +## License |
| 97 | +Copyright (c) 2022 Oracle and/or its affiliates. |
| 98 | + |
| 99 | +Released under the Universal Permissive License v1.0 as shown at <https://oss.oracle.com/licenses/upl/>. |
| 100 | + |
| 101 | +[mle-js-oracledb]: http://oracle-samples.github.io/mle-modules/docs/mle-js-oracledb/21c "[email protected]" |
| 102 | +[mle-js-bindings]: http://oracle-samples.github.io/mle-modules/docs/mle-js-bindings/21c "[email protected]" |
| 103 | +[mle-js-plsqltypes]: http://oracle-samples.github.io/mle-modules/docs/mle-js-plsqltypes/21c "[email protected]" |
| 104 | +[1]: https://medium.com/graalvm/mle-executing-javascript-in-oracle-database-c545feb1a010 "Multilingual Engine: Executing JavaScript in Oracle Database" |
| 105 | +[2]: https://blogs.oracle.com/apex/post/mle-and-the-future-of-server-side-programming-in-oracle-apex "MLE and the Future of Server-Side Programming in Oracle APEX" |
| 106 | +[3]: https://docs.oracle.com/en/database/oracle/oracle-database/21/index.html "Oracle Database 21c" |
0 commit comments