8.3 Managing MLE Environments

MLE environments are schema objects that can be managed in the database. You can create, edit and delete MLE environments using Database Actions.

Creating an MLE Environment

To create an MLE environment:

  1. In the left pane, select the Navigator tab, select Object submenu and click Create Object.

    The Create MLE Environment panel appears.

  2. Select the schema from the list. By default, the current schema is used.

  3. In the Name field, enter a name for the environment.

  4. Select the appropriate Language Options. For more information, see JavaScript Language Options in JavaScript Developer's Guide.

  5. The Available Modules field automatically populates the modules available for the selected schema. Select one or more modules. Click the Add Selected Modules icon or the Add All Modules icon to move the modules to the Imported Modules field. You can edit the Import Name field for the module if needed.

    When a single module is selected, the Add module with dependencies icon becomes available. Click this icon to find environments where the module is used and also to add other modules that the selected module depends on.

    To view the code for a module, in the Available Modules field, right-click the module and select Details.

  6. The DDL pane displays the code for the new MLE environment. Click Create.

    The MLE environment is saved and appears in the left pane under Environments.

Context Menu Options

In the left pane, right-click the MLE environment to view the following options:

  • Edit: Select to edit the MLE environment. You can modify the language options, add more modules to import or change the import names for the modules.
  • Drop: Select to drop the environment from the database.
  • Compile: Select to compile or recompile the environment.
  • Dependencies Diagram: Shows the imported modules and exported functions for each module in the environment using a diagram.

See Example: Creating an MLE Environment for an example of how to create an MLE environment.

8.3.1 Example: Creating an MLE Environment

This example demonstrates the creation of an MLE environment and demonstrates how a mapping is created between the identifier FACTORIAL_MOD and the JavaScript module FACTORIAL_MOD created in Example: Creating an MLE Module.

Create the MLE Environment

  1. In the MLE JS page, in the left pane, select Environments from the object type selector and then click Object submenu - Create Object.
    The Create MLE Environment panel appears.
  2. In the Name field, enter myfactorialenv.
  3. In the Available Modules field, select FACTORIAL_MOD. Click Add Selected Module to move the module to the Imported Modules field.

    Note:

    By default, the Import Name matches the Module name. You can edit the import name by clicking in the associated column cell and typing in the new name.
  4. Click Create.
    The Output pane displays the underlying source code along with a CREATED notification.
  5. Click Close.
    The new environment is now available in the left Navigator pane. (If you do not see it, click Refresh in the left pane.)

Create the MLE module that Imports FACTORIAL_MOD

  1. In the MLE JS page, in the left pane, select Modules from the object type selector and then click Object submenu - Create Object.
  2. In the right pane, select the Editor tab, and enter the following JavaScript function:
    import * as h from "FACTORIAL_MOD";
    
    export function factorial_3(){
        console.log('The factorial of 3 is:' + h.factorial(3));
    }
    
  3. In the Name field, enter mod_imp_fact.
  4. In the Environment field, select MYFACTORIALENV.
  5. Click Save Module.
    A notification that the module is saved in the database is displayed.