11 ORDS_EXPORT_ADMIN PL/SQL Package Reference

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

The ORDS_EXPORT_ADMIN package enables users to export REST-enabled objects within a schema with the ORDS_ADMINISTRATOR_ROLE role. Administrators can selectively export specific REST-related artifacts using the provided schema name and additional parameters. This capability is particularly useful for documenting and migrating REST services as it ensures that only the necessary objects are included.

The following sections explains on how the parameters are used to provide fine-grained control over the export process and cater to various administrative needs.

11.1 ords_export_admin.export_schema

Format

FUNCTION ords_export_admin.export_schema(
  p_schema                  IN VARCHAR2,
  p_include_modules         IN BOOLEAN DEFAULT TRUE,
  p_include_privileges      IN BOOLEAN DEFAULT TRUE,
  p_include_roles           IN BOOLEAN DEFAULT TRUE,
  p_include_oauth           IN BOOLEAN DEFAULT TRUE,
  p_include_rest_objects    IN BOOLEAN DEFAULT TRUE,
  p_include_jwt_profiles    IN BOOLEAN DEFAULT TRUE,
  p_include_enable_schema   IN BOOLEAN DEFAULT TRUE,
  p_export_date             IN BOOLEAN DEFAULT TRUE,
  p_runnable_as_admin       IN BOOLEAN DEFAULT TRUE
)
RETURN CLOB;
Description

ords_export_admin.export_schema function is only valid for exporting the schemas that are previously REST-enabled.

Table 11-1 Parameters

Parameter Description
p_schema Specifies the name of the REST-enabled schema you want to export.
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 privileges call 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_object 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 date when the export is made is included in the header export. Set the value to TRUE to include the calls, otherwise set the value to FALSE.
p_runnable_as_admin Specifies whether Public or Admin packages are used in the exported script. Set the value to TRUE if the exported script is planned to run as an administrator user targeting another schema, otherwise set the value to FALSE if current user is the target schema.

Examples

Example 11-1 Exporting with defaults

Following is an example of exporting the schema with all the boolean parameters set as default to TRUE. The exported script contains all the objects.

DECLARE
  v_exported_script CLOB;
BEGIN
  v_exported_script := ORDS_EXPORT_ADMIN.EXPORT_SCHEMA(
    P_SCHEMA => 'TEST_SCHEMA'
  );
END;

Example 11-2 Exporting with parameters

Following example uses all the optional parameters to indicate:
  • Not to include the JWT profiles in the export script
  • Output script does not have the exported date (useful to run the differences)
DECLARE
  v_exported_script CLOB;
BEGIN
  v_exported_script := ORDS_EXPORT_ADMIN.EXPORT_SCHEMA(
    P_SCHEMA => 'TEST_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,
    P_RUNNABLE_AS_ADMIN => TRUE
  );
END;

11.2 ords_export_admin.export_module

Format

FUNCTION ords_export_admin.export_module(
    p_schema                    IN VARCHAR2,
    p_module_name               IN VARCHAR2,
    p_include_enable_schema     IN BOOLEAN DEFAULT TRUE,
    p_include_privleges         IN BOOLEAN DEFAULT TRUE,
    p_privs_with_other_mod_refs IN BOOLEAN DEFAULT TRUE,
    p_export_date               IN BOOLEAN DEFAULT TRUE,
    p_runnable_as_admin         IN BOOLEAN DEFAULT FALSE
) 
RETURN CLOB;
Description
ords_export_admin.export_module function is only valid for exporting modules by name in schemas that are previously REST-enabled.

Table 11-2 Parameters

Parameter Description
p_schema Specifies the name of the REST-enabled schema containing the module you want to export.
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 a call to enable_schema is included in the export. Set the value to TRUE to include the call, otherwise set the value to FALSE.
p_include_privileges Specifies whether the privileges and roles 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 Specifies whether the privileges being exported include references to modules other than the module 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 will be included in the header export. Set the value to TRUE to include the calls. Otherwise, set the value to FALSE.
p_runnable_as_admin Specifies whether public or admin packages are used in the exported script. Set the value to TRUE if the exported script is planned to run as an administrator user targeting another schema. Otherwise, set the value to FALSE if the current user is the target schema.

Examples

Following is an example of exporting the module in a schema using only the required parameters (using defaults for the rest).

Example 11-3 Exporting with defaults

The exported script contains the following:
  • Call to REST enable the schemaDefinition of roles and privileges
  • The date when the export was run (export date)
  • Calls to ORDS public (non-admin) packages
DECLARE
  v_exported_script CLOB;
BEGIN
  v_exported_script := ORDS_EXPORT_ADMIN.EXPORT_MODULE(
    P_SCHEMA => 'TEST_SCHEMA',
    P_MODULE_NAME => 'module_1'
  );
END;

Example 11-4 Exporting with parameters

Following is an example using all the optional parameters to:
  • Include call to enable_schema
  • Include roles and privileges
  • Include reference to other modules protected by privilege
  • Not include export_date
  • Use the ORDS Admin packages in the code
DECLARE
  v_exported_script CLOB;
BEGIN
  v_exported_script := ORDS_EXPORT_ADMIN.EXPORT_MODULE(
    P_SCHEMA => 'TEST_SCHEMA',
    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,
    P_RUNNABLE_AS_ADMIN => TRUE
  );
END;