Defining source overrides

You can override the default data server connections, catalogs, or schemas that the data module is based on. As a result, the module can dynamically switch to a different source (data server connection, schema, or catalog) at run time, without any intervention from a user.

Source overrides are supported only for data modules that are based on data servers. If you reference a data module in which override values are specified in another data module, the override values are maintained.

Note: Source overrides are not supported for data modules that are based on packages, uploaded files, and data sets.

Dynamic source overrides are useful when the development, test, and production environments use different data server connections, schemas, or catalogs, or in a multi-tenant application where each tenant uses a different instance of the same database schema or catalog.

About this task

Use the Override property on a data server connection, schema, or catalog to specify the override values. The following screen capture shows the override properties for the sales schema:

The Override checkbox determines if the default value or the override value of the property is used. If the checkbox is selected, the specified override value is used. If the checkbox is clear, the default value is used.

Note: The default values are derived from the data server schema or catalog that was used during metadata import, or from the schema or catalog that was used for relinking.

The override value can be a string, which is a name of a data server connection, schema, or catalog that exists in your data server, or a macro. In a macro, you can use session parameters, such as tenantID, machine, or account.personalInfo.userName.

Procedure

  1. From Team content, open your data module.
  2. Expand the Sources Source view icon panel.
  3. From the source (schema or catalog) context menu Vertical actions menu icon, select Properties.
  4. On the General tab, scroll down to the Advanced section, and expand this section.

    The Override property is available for Data server connection, Schema, and Catalog.

  5. Select the Override checkbox, and click the Value link.

    The override expression editor is displayed.

  6. Add the override value in the Expression area.

    If the value is a simple string, type the string.

    Source override editor

    If the value is a macro, type the macro text within the macro tags ##. Comments that are associated with a macro must be included within the macro itself.

    For example, the following macro is used to dynamically switch to another source when the data module is used in the development environment, testing environment, or production environment.

    #let datasource =
    case $machine
    when 'Holst' then 'GOSLDW_DNB_DB2'
    /* this is the development machine */
    when 'Scarlatti' then 'GOSLDW_DNB_MSSQL_TEST'
    /* this is the testing machine */
    when 'Buxtehude' then 'GOSLDW_DNB_DB2_SECURED'
    /* this is the production machine */
    else 'nothing'
    end;
    datasource #

    In this example, the preview shows the value of GOSLDW_DNB_DB2 because the machine name is Holst. This is the override value for the data server connection.

    Source override editor
    Note: If the database doesn't use catalogs, the default override value for Catalog is null. And if the database doesn't use schemas, the default override value for Schema is null.

Results

Both the default values and the override values are stored in the data module, and persist from session to session. If you clear any of the Override checkboxes, the default value is restored and displayed. If you select the checkbox again, the override value is restored and displayed.

If you relink a schema or catalog, the override property values are removed from the data module. To restore these properties, click the undo button Icon to undo an action. However, consider whether you need to relink manually since the override properties allow you to relink dynamically.