Support for Multilingual Engine

Note

This feature is not available for MySQL database services.
SQL Worksheet supports the Multilingual Engine (MLE) feature enabling you to run JavaScript code in the worksheet.

Prerequisites

For the availability of MLE features, you need the:

  • DBMS_MLE package in Oracle Database Release 21c and later versions. For more information, see DBMS_MLE in Oracle Database PL/SQL Packages and Types Reference.

  • EXECUTE DYNAMIC MLE and EXECUTE ON JAVASCRIPT privileges assigned to you.

You can work with JavaScript code in the worksheet in the following ways:

  • Create a JavaScript worksheet
  • Execute JavaScript code in a standard worksheet
  • Execute JavaScript code as a PL/SQL block

Create a JavaScript Worksheet

You can open the worksheet in JavaScript mode. In this mode, the toolbar icons and output tabs will change to support JavaScript code development.

To create and save a JavaScript worksheet:

  1. In the toolbar, expand the New File icon and select JavaScript.
  2. When you enter code in the worksheet, the JavaScript code is automatically highlighted.
  3. Execute the JavaScript code in the worksheet using Run Script.
  4. Click Save.

    In the Files pane, (JS) is added to the JavaScript file name. This enables you to quickly identify the JavaScript file.

This image shows JavaScript code executed in a JavaScript worksheet.

Execute JavaScript code in a standard worksheet

In a standard worksheet (when the worksheet is not in JavaScript mode):

  1. Select the JavaScript code to execute.
  2. In the worksheet toolbar, expand the Run Script icon and select Run as JavaScript.
    Note

    Selecting Run as SQL script results in an error.
This image shows JavaScript code executed in a standard worksheet.

Execute JavaScript code as a PL/SQL block

You can use a PL/SQL code block to execute JavaScript code.

From the worksheet toolbar, expand the Run Script icon and select Run as SQL script (F5).

This image shows JavaScript code executed as a PL/SQL code block in the SQL Worksheet.