11 ORDS_EXPORT PL/SQL Package Reference

This section describes how the ORDS_EXPORT package enables users to export REST-enabled objects within a schema.

The ORDS_EXPORT PL/SQL package enables the users to export Oracle REST Data Services (ORDS) metadata as a PL/SQL script which can then be executed to recreate the metadata. This facilitates migration, backup, and deployment of ORDS configurations.

11.1 EXPORT_SCHEMA

Format

FUNCTION export_schema(
   p_include_modules       IN BOOLEAN,
   p_include_privileges    IN BOOLEAN,
   p_include_roles         IN BOOLEAN,
   p_include_oauth         IN BOOLEAN,
   p_include_rest_objects  IN BOOLEAN,
   p_include_jwt_profiles  IN BOOLEAN,
   p_include_enable_schema IN BOOLEAN,
   p_export_date           IN BOOLEAN
) RETURN CLOB;
Description
The export_schema function enables the users to export REST modules, templates, handlers, privileges, roles, OAuth clients, REST Objects, and JWT profiles within the CURRENT_SCHEMA.

Table 11-1 Parameters

Parameter Description
p_include_modules Specifies whether modules/templates/handlers/parameters calls are included in the export. Set the value to TRUE to include the calls, otherwise set the value to FALSE.
p_include_privileges Specifies whether all privilege calls are included in the export. Set the value to TRUE to include the calls otherwise, set the value to FALSE.
p_include_roles Specifies whether all the role calls are included in the export. Set the value to TRUE to include the calls. Otherwise, set the value to FALSE.
p_include_oauth Specifies whether all Oauth client calls are included in the export. Set the value to TRUE to include the calls. Otherwise, set the value to FALSE.
p_include_rest_objects Specifies whether all REST-object calls are included in the export. Set the value to TRUE to include the calls. Otherwise set the value to FALSE.
p_include_jwt_profiles Specifies whether JWT profile call is included in the export. Set the value to TRUE to include the calls. Otherwise set the value to FALSE.
p_include_enable_schema Specifies whether
ORDS.ENABLE_SCHEMA
call is included in the export. Set the value to TRUE to include the calls. Otherwise, set the value to FALSE.
p_export_date Specifies whether the export date is included in the header export. Set the value to TRUE to include the calls. Otherwise, set the value to FALSE.

Examples

Example 11-1 Export schema

DECLARE
  v_exported_script CLOB;
BEGIN
  v_exported_script := ORDS_EXPORT.EXPORT_SCHEMA();
END;

Example 11-2 Customizing content using parameters

The export_schema function enables the users to customize the items going to be included in the output script.

DECLARE
  v_exported_script CLOB;
BEGIN
  v_exported_script := ORDS_EXPORT.EXPORT_SCHEMA(
    P_INCLUDE_MODULES => TRUE,
    P_INCLUDE_PRIVILEGES => TRUE,
    P_INCLUDE_ROLES => TRUE,
    P_INCLUDE_OAUTH => TRUE,
    P_INCLUDE_REST_OBJECTS => TRUE,
    P_INCLUDE_JWT_PROFILES => FALSE,
    P_INCLUDE_ENABLE_SCHEMA => TRUE,
    P_EXPORT_DATE => FALSE
  );
END;

11.2 EXPORT_MODULE

Format

FUNCTION export_module (
   p_module_name             IN VARCHAR2,
   p_include_enable_schema   IN BOOLEAN ,
   p_include_privs           IN BOOLEAN ,
   p_privs_with_other_mod_refs   IN BOOLEAN DEFAULT FALSE,
   p_export_date             IN BOOLEAN DEFAULT TRUE
) RETURN CLOB;
Description
The export_module function exports a specified module, including templates/handlers, roles and privilege, and reference to other modules secured with the same privilege.

Table 11-2 Parameters

Parameter Description
p_module_name Specifies the name of the module to be exported. The exported module includes the defined templates, handlers, and parameters.
p_include_enable_schema Specifies whether the ORDS.ENABLE_SCHEMA call is included in the export. Set the value to TRUE to include the calls. Otherwise, set the value to FALSE.
p_include_privs Specifies whether the privilege and role associated with the module are included in the export. Set the value to TRUE to include the calls. Otherwise, set the value to FALSE.
p_privs_with_other_mod_refs whether the exported privileges include references to modules other than the one specified in p_module_name. Set the value to TRUE for privilege definitions to include references to all modules. Otherwise, set the value to FALSE for privilege definitions to only refer to the module being exported.
p_export_date Specifies if the date when the export was made is included in the header export. Set the value to TRUE to include the calls. Otherwise, set the value to FALSE.

Examples

Example 11-3 Export REST module

The export_module function enables the users to use the name of the module. By default, the exported code includes the following:
  • Module definition
  • Templates and handlers contained in the module
  • Privilege and role associated to the module
  • Call to REST enable the schema
  • Export Date
DECLARE
  v_exported_script CLOB;
BEGIN
  v_exported_script := ORDS_EXPORT.EXPORT_MODULE(
    P_MODULE_NAME => 'module_1'
  );
END;

Example 11-4 Export customizing content using parameters

The export_module function enables the users to customize which items are included in the output script.

DECLARE
  v_exported_script CLOB;
BEGIN
  v_exported_script := ORDS_EXPORT.EXPORT_MODULE(
    P_MODULE_NAME => 'module_1'
    P_INCLUDE_ENABLE_SCHEMA => TRUE,
    P_INCLUDE_PRIVILEGES => TRUE,
    p_PRIVS_WITH_OTHER_MOD_REFS => TRUE,
    P_EXPORT_DATE => FALSE
  );
END;

11.3 EXPORT_OAUTH_CLIENT

Format

FUNCTION export_oauth_client (
   p_client_name                            IN VARCHAR2,
   p_include_security_definitions           IN BOOLEAN,
   p_export_date                            IN BOOLEAN DEFAULT TRUE
) RETURN CLOB;
Description
The export_oauth_client function exports OAuth clients by name from the current schema provided the schema has been previously REST-enabled.
Export can include:
  • Privilege and role associated with the OAuth Client
  • Export generation date

Table 11-3 Parameters

Parameter Description
p_client_name Specifies the name of OAuth client to be exported.
p_include_security_definitions Specifies whether the privilege and role associated with the OAuth client are included in the export. Set the value to TRUE to include them. Otherwise, set the value to FALSE.
p_export_date Specifies whether the export date is included in the header of the export file. Set the value to TRUE to include it. Otherwise, set the value to FALSE.

Example 11-5 Exporting OAuth Client

The export_oauth_client function enables the users to select which items are included in the output script.


DECLARE
  v_exported_script CLOB;
BEGIN
  v_exported_script := ORDS_EXPORT.EXPORT_OAUTH_CLIENT(
    P_CLIENT_NAME => 'client_1',
    P_INCLUDE_SECURITY_DEFINITIONS => TRUE,
    P_EXPORT_DATE => FALSE,
  );
END;