3.3 Managing JavaScript Modules
The SQL Developer extension for VS Code enables you to access and manage MLE (Multilingual Engine) objects such as MLE modules.
For more information about MLE, see Introduction to Oracle Database Multilingual Engine in the Oracle Database JavaScript Developer's Guide.
SQL Developer for VS Code allows the creation of JavaScript modules as schema objects, assuming the necessary privileges are in place. JavaScript module is a unit of MLE's language code stored in the database as a schema object. You can create, edit and delete JavaScript modules.
The actions available are:
3.3.1 Create a JavaScript Module
3.3.1.1 Example for Create a JavaScript Module
This example demonstrates the creation of the factorial_mod JavaScript module.
- In the Connections panel, click the + icon in the JavaScript Modules node and then click Create.
- In the MLE Module Name field, enter factorial_mod.
-
Click Apply.
The module appears under JavaScript Modules in the Connections panel.
-
In the Connections panel, expand JavaScript Modules, right-click factorial_mod and select Open.
The factorial_mod module pane appears.
- Enter the following JavaScript function:
export function factorial(num) { if(num < 0) { return -1; } else if (num == 0) { return 1; } else { return(num * factorial(num-1)); } }
- Click the Compile icon to save the
JavaScript code.
Note:
Alternatively, you can save the code by usingctr + s
orcmd + s
.
To import a module to an MLE environment, see Example for Create an MLE Environment.
3.3.3 Show JavaScript Module Details
To show details about a selected module, after opening the module, click the Show Details Panel icon, which is located right next to the Compile icon.
The Details panel has three tabs: Privileges, Details and Errors.
If there are any errors in the saved module, the line and position column displays the line,position as a link that takes the cursor to the exact location of the syntax error in the module's file.
You can hide the Details panel by clicking the Hide Details Panel icon.
3.3.4 Compile JavaScript Module
To compile a selected JavaScript module:
-
In the Connections panel, select the module to compile, right-click and select Compile.
The Compile panel appears.
-
Click Apply.
To compile all MLE modules for the connection, right-click JavaScript Modules and select Compile All.
To compile all invalid modules for the connection, right-click JavaScript Modules and select Compile All Invalid.