Skip to content

Oracle SQL Server Transformation

Oracle SQL Server Transformation is used in the Enterprise version of process.science for Power BI to prepare the data. The package is designed to transform the data from the Oracle database into a form that is suitable for Power BI. It creates four tables that can be used for analysis in Power BI.

Preparing the input table

Before the scripts can be used, you must ensure that your input table fulfils the following requirements. The column names for case_id, activity and timestamp are fixed and must be present in your input table. The other names can be changed in the script.

Field NameDescriptionData TypeMandatory
case_idThrough this field the process instances can be differentiated.NVARCHAR2
activityThis field describes the activity that has taken place.NVARCHAR2
activity_groupedThis field describes the group of the activity that has taken place.NVARCHAR2
timestampThis field describes when an event has taken place.TIMESTAMP
timestamp_endThis field can be used to calculate the duration of activities.TIMESTAMP
sort_keyThis field can be used to adjust the sorting of the event log.NUMBER
valueThis allows you to set the costs for the current event.NUMBER
automatedThis allows you to set wether the activity was automated or not.NUMBER
resourceThis allows you to set user information for each activity.‚Any
Additional Activity ValuesFurther information per activity, e.g. quantity of items. All fields, not matching other names will be mapped as additional activity values and will be stored in the newly created event log table.Any
Additional Cases ValuesFurther information per case, e.g. a company division. All fields starting with case_ will be mapped as additional cases values and will be stored in the newly created cases table.Any
Additional Activity Values GroupedFurther information per activity group, e.g. quantity of items. All fields ending with _grouped will be mapped as additional activity group values and will be stored in the newly created event log table.Any

Downloading the scripts

The scripts can always be downloaded in the latest version from our Self Service Portal. The scripts are contained in a ZIP file and must be unpacked.

Installation and configuration

Customise schema

The schema for input and output must be adapted in the scripts. This is done in script 6_PerformTransformation.sql.

Creating the helper functions

  1. open the script 0_CreateHelperProcedures.sql and execute it in your database.
  2. the script creates the functions PS_TIMESTAMP_DIFF and PS_CHECK_COLUMN_EXISTS in your output schema.

Creating the static tables

  1. open the script 1_CreateStaticTables.sql and execute it in your database.
  2. the script creates the tables filter_and, filter_or and if the grouped calculation is to take place also the tables filter_and_grouped, filter_or_grouped and activity_group_map in your output schema.

This script must be executed whenever the structure of the input table changes.

Creating the procedures

The next step is to create the procedures that write the data to the tables. To do this, the scripts 2_CreateEventLogProcedure.sql, 3_CreateEventLogGroupedProcedure.sql, 4_CreateAdditionalGroupedTablesProcedure.sql , 5_CreateCasesDataProcedure.sql must be executed. This only needs to be done once.

Event Log

The procedure PS_CREATE_EVENT_LOG_TABLE creates the table eventlog in your output schema and fills it with the data from the input table. All additional columns that do not begin with case_ or end with _grouped are saved in the eventlog table.

sql
CREATE OR REPLACE PROCEDURE PS_CREATE_EVENT_LOG_TABLE (
    SCHEMA_NAME_IN IN NVARCHAR2,
    SCHEMA_NAME_OUT IN NVARCHAR2,
    TABLE_NAME_INPUT IN NVARCHAR2,
    ACTIVITY_GROUPED_NAME IN NVARCHAR2,
    TIMESTAMP_END_NAME IN NVARCHAR2,
    VALUE_NAME IN NVARCHAR2,
    AUTOMATED_NAME IN NVARCHAR2,
    RESOURCE_NAME IN NVARCHAR2,
    SORT_KEY_NAME IN NVARCHAR2
)

If the dynamic columns (timestamp_end, sort_key, value, automated and resource) are not present in the input table, they are automatically filled with default values.

Event log grouped

The procedure PS_CREATE_EVENT_LOG_GROUPED_TABLE creates the table eventlog_grouped in your output schema and fills it with the data from the input table. This script is only executed if the grouped calculation is to take place, i.e. the activity_grouped column is present in the input table. All additional columns with the suffix _grouped are saved in the eventlog_grouped table.

sql
CREATE OR REPLACE PROCEDURE PS_CREATE_EVENT_LOG_GROUPED_TABLE (
    SCHEMA_NAME_IN IN VARCHAR2,
    SCHEMA_NAME_OUT IN VARCHAR2,
    TABLE_NAME_INPUT IN VARCHAR2,
    ACTIVITY_GROUPED_NAME IN VARCHAR2,
    TIMESTAMP_END_NAME IN VARCHAR2,
    VALUE_NAME IN VARCHAR2,
    AUTOMATED_NAME IN VARCHAR2,
    RESOURCE_NAME IN VARCHAR2,
    SORT_KEY_NAME IN VARCHAR2,
    PERFORM_GROUPED_CALCULATION OUT BOOLEAN
)

Additional Grouped Tables

The procedure PS_CREATE_ADDITIONAL_GROUPED_TABLES creates the tables filter_and_grouped and filter_or_grouped. This procedure is only executed if the grouped calculation is to take place.

sql
CREATE OR REPLACE PROCEDURE PS_CREATE_ADDITIONAL_GROUPED_TABLES(
    SCHEMA_NAME_OUT IN NVARCHAR2,
    PERFORM_GROUPED_CALCULATION IN BOOLEAN
)

Cases table

The procedure PS_CREATE_CASES_DATA_TABLE creates the table cases_data in your output schema and fills it with the data from the input table. All additional columns beginning with case_ are saved in the cases_data table.

sql
CREATE OR REPLACE PROCEDURE PS_CREATE_CASES_DATA_TABLE(
    SCHEMA_NAME_IN IN NVARCHAR2,
    SCHEMA_NAME_OUT IN NVARCHAR2,
    TABLE_NAME_INPUT IN NVARCHAR2,
    PERFORM_GROUPED_CALCULATION IN BOOLEAN
)

Loading the data

To load the data, the script 6_PerformTransformation.sql must be executed. This script calls the procedures that write the data to the tables. In this script, the information on the input table and the dynamic columns must be adapted above.

sql
DECLARE
 -- **************** Define the table and column names here ********************** --
    SCHEMA_NAME_IN              NVARCHAR2(10) := 'ADMIN'; -- Change input schema name here
    SCHEMA_NAME_OUT             NVARCHAR2(10) := 'ADMIN'; -- Change output schema name here
    TABLE_NAME_INPUT            NVARCHAR2(100) := 'EVENTLOG_EN'; -- Change input event log name here
    ACTIVITY_GROUPED_NAME       NVARCHAR2(50) := 'ACTIVITY_GROUPED'; -- Change activity_grouped column name here
    TIMESTAMP_END_NAME          NVARCHAR2(50) := 'TIMESTAMP_END'; -- Change timestamp_end column name here
    VALUE_NAME                  NVARCHAR2(50) := 'ACTIVITY_COST'; -- Change value column name here
    AUTOMATED_NAME              NVARCHAR2(50) := 'AUTOMATED'; -- Change automated column name here
    RESOURCE_NAME               NVARCHAR2(50) := 'RESOURCE'; -- Change RESOURCE column name here
    SORT_KEY_NAME               NVARCHAR2(50) := 'SORT_KEY'; -- Change sort_key column name here
    PERFORM_GROUPED_CALCULATION BOOLEAN; -- DO NOT CHANGE OR REMOVE
 -- **************** Define the table and column names here ********************** --