Database Procedures

This chapter lists the most commonly needed database procedures.

This chapter covers the following topics:

Recommended Procedure Scheduling

The following table lists the most important predefined procedures provided by Demantra. You should schedule all these procedures to run periodically from workflows.

Procedure Recommended to run...
ANALYZE_SCHEMA run after the first import, and then once per week (for example, by running the Scheduled Cleanup Tasks workflow)
run after running REBUILD_INDEXES and REBUILD_TABLES
CHAINING every 10 seconds
COMPUTE_STD_ERR once a week, if you are performing standard error calculations*
DROP_TEMP_TABLES once per week (for example, by running the Scheduled Cleanup Tasks workflow)
MANUALS_INS every 10 seconds, if you are using the desktop products (Demand Planner and Demand Replenisher)
REBUILD_INDEXES** once a week, on a weekend day*
REBUILD_TABLES** run after the first import
run once a week, on a weekend day*
SCHEDULED_CLEANUP_TASKS once a week, on Saturdays (this is the default)
*It is recommended that you run each of these procedures at off hours and at staggered times to avoid deadlock issues. **These procedures require tablespace equal in size to the current tablespace.

ANALYZE_SCHEMA

Oracle only. Analyzes all the tables in the schema. By default, this procedure runs once a week as part of the Scheduled Cleanup Tasks workflow.

API_CONFIG_SETTLEMENT

DSM associates settlements with an item and a location level and is shipped pre-configured to an existing item and location level. If you want to change this information, run the procedure API_CONFIG_SETTLEMENT.

This procedure:

For details, see "Setting up Database Structures" in the Configuring DSM chapter.

APPPROC_REBUILD_CONTEXT_CACHES

The APPPROC_REBUILD_CONTEXT_CACHES stored procedure automates the creation of caches for worksheets that use the Open With functionality and where the Open With Context for the worksheet is set to Selected Member.

This procedure simulates the user open with action which allows worksheet caches to be created in a batch process thereby eliminating the need to build the cache the first time the user opens the worksheets.

Note: This procedure improves the efficiency of building common caches by creating a cache for one user and copying it to other users instead of creating the cache for each user. This is accomplished by specifying a User Group. When common caches are detected, the cache is created for one of the Users in the User Group and copied to other Users in the User Group that require the same cache.

This procedure checks User security only on the Open With Level when creating and copying caches. It is important to structure the User Groups to be used by this procedure so that all Users have common security for all levels other than the Open With Level of the Worksheet that the cache is being built for.

This procedure must be incorporated into a workflow that also runs the Worksheet Cache Step. See Worksheet Caching > Creating a Workflow to Build Worksheet Caches Automatically.

The APPPROC_REBUILD_CONTEXT_CACHES stored procedure has the following requirements:

The worksheet to be cached:

The level

In addition, a User Group must exist that contains all of the Users for which caches are to be built.

Following are the parameters for the APPPROC_REBUILD_CONTEXT_CACHES stored procedure. You set these parameters in the Stored Procedure Step Properties dialog in Workflow Manager:

Identifying the Members of the Open With Level to Cache

For each Member of the Open With Level for the Worksheet being cached, the APPPROC_REBUILD_CONTEXT_CACHES stored procedure requires a flag to indicate whether or not the member should be cached.

To set this up, perform the following:

  1. In Business Modeler (Configure > Configure Levels), on the Open With level for the worksheet that you want to cache, create an attribute named CAN_CREATE_CW.

  2. Set the value of the CAN_CREATE_CW attribute to 1 for all Level Members that you want to build caches for. You can set this value through any method you select such as a worksheet, data load process, or database procedure.

This setting applies to all worksheets that are cached using the APPPROC_REBUILD_CONTEXT_CACHES stored procedure for the particular Open With level.

CHAINING

Checks the chaining queue for any pending chaining operations; performs those operations.By default, this procedure runs once a week as part of the Scheduled Cleanup Tasks workflow.

CLEAN_LOG_TABLES

Removes old data from the db_exception_log and audit_trail tables. To determine which data to keep, this procedure checks the value of the audit_history_length parameter, which you can access in the Business Modeler. By default, this procedure runs once a week as part of the Scheduled Cleanup Tasks workflow.

COMPUTE_STD_ERR

Performs any pending standard error calculations.

CREATE_OPT_STRUCT

Creates the default database structures needed for the Promotion Optimization module. The installer runs this procedure, if you choose to set up a default Promotion Optimization environment.

For details, see “Other Configuration for PTP”.

CREATE_PE_STRUCT

Creates the default database structures needed for Promotion Effectiveness.

Demantra provides the Promotion Effectiveness (PE) structures by default. Therefore, the CREATE_PE_STRUCT procedure should be run only after creating a new or custom data model from scratch (this is not common or recommended); only in this scenario would these structures not already be in place. To determine whether PE structures exist, search the DB for table names containing %PROMOTION%.

For details, see “Configuring Promotion Effectiveness”.

DELETE_FORE_COL

Deletes all the history data from the current forecast column, for all combinations for which prediction_status equals 1. The procedure deletes history, starting at the date given by max_sales_date - ForecastGenerationHorizon.

ForecastGenerationHorizon is an engine parameter; see “Engine Parameters”.

DELETE_INVALID_GL_POPULATION

Checks the promotion_data table for invalid records and deletes them.

DROP_TEMP_TABLES

Deletes temporary database tables that are created, for example, when modifying worksheets, launching integration profiles, or running the Analytical Engine.

By default, this procedure runs once a week as part of the Scheduled Cleanup Tasks workflow.

EP_LOAD_MAIN

Performs the data loading described in the Data Model Wizard. Specifically, this procedure loads data from the staging tables specified within the Data Model Wizard and writes records in sales_data and other internal tables as needed.

This procedure is created by the Data Model Wizard and thus is different in different implementations.

EP_LOAD_MDP_LEVEL

EP_LOAD_MDP_LEVEL is the main method of populating matrix levels. During data load, information from sales master that is not time dependant can be loaded to these levels.

The following parameters are used with the EP_LOAD_MDP_LEVEL procedure:

Ep_Load_Mdp_LevelUseParallelDML
Description If you run DML statements, any objects with a parallel degree configured will be run in parallel.Individual parallel hints setting will supersede this setting.
Values TRUE - LOAD_MDP_LEVEL should use PARALLEL DML on objects that are set as parallel.FALSE - LOAD_MDP_LEVEL should not use PARALLEL DML on objects that are set as parallel.
Default Value FALSE
Ep_Load_Mdp_LevelUseParallel
Description Set this parameter to FALSE when you do not want to use parallel hints in the EP_LOAD_MDP_LEVEL script.Should be set to FALSE when database resources may be limited.
Values TRUE - MDP_ADD will use PARALLEL hints.FALSE - MDP_ADD will not use PARALLEL hints.
Default Value TRUE
Ep_Load_Mdp_LevelUseOneCommit
Description Set this parameter to FALSE if the database is relatively small and has smaller rollback segments. If your database is powerful and thus sufficient resources are available, then set this parameter to TRUE.
Values TRUE - EP_LOAD_MDP_LEVEL executes only one commit.FALSE - EP_LOAD_MDP_LEVEL executes multiple commits.
Default Value FALSE
Ep_Load_Mdp_LevelSetProp_Changes
Description This parameter determines whether the MDP_ADD process will set PROP_CHANGES to 1. PROP_CHANGES are used to calculate status and proportions of MDP_MATRIX combinations.This parameter should be set to FALSE if another process calls the PROPORT procedure or status and proportions are defined during a different process.
Values TRUE - Set PROP_CHANGES = 1 during EP_LOAD_MDP_LEVEL.FALSE - Do not set PROP_CHANGES = 1 during EP_LOAD_MDP_LEVEL.
Default Value FALSE
Ep_Load_Mdp_LevelDisableEnableIndexes
Description This parameter determines whether the MDP_ADD process will set PROP_CHANGES to 1. PROP_CHANGES are used to calculate status and proportions of MDP_MATRIX combinations.This parameter should be set to FALSE if another process calls the PROPORT procedure or status and proportions are defined during a different process.
Values TRUE - Set PROP_CHANGES = 1 during EP_LOAD_MDP_LEVEL.FALSE - Do not set PROP_CHANGES = 1 during EP_LOAD_MDP_LEVEL.
Default Value FALSE
Ep_Load_Mdp_LevelDisableEnableIndexes
Description Controls whether to drop indexes on a table when loading MDP_LEVEL information.. MDP indexes are rebuilt after execution.
Values TRUE - Disable and then enable (rebuild) indexes.FALSE - Indexes remain in place during the updates.
Default Value FALSE
Ep_Load_Mdp_LevelIndexRebuildDegree
Description If rebuilding indexes using Ep_Load_Mdp_LevelDisableEnableIndexes, this parameter specifies which degree to use.
Values ---
Default Value 4
Ep_Load_Mdp_LevelUseMerge
Description This parameter controls the MDP_MATRIX update method. Choose either Merge or Cursor.For larger data sets, with appropriate database resources, MERGE should be faster.
Values TRUE - Use the MERGE update method.FALSE - Use the CURSOR update method.
Default Value TRUE
Details DELETE mdp_matrix WHERE NOT EXISTS (SELECT ... SALES_DATA s) AND NOT EXISTS (SELECT hint PROMOTION_DATA s))
DBHintEp_Load_Mdp_LevelMerge
Description SQL hint to use when Ep_Load_Mdp_LevelUseMerge is set to MERGE.This parameter defines the degree used during the Merge.
Values TRUE - Use the MERGE update for the MDP_MATRIX cache columns - FROM_DATE and UNTIL_DATE.FALSE - Use a cursor loop.
Default Value + full (a) parallel (a 20)
Details Example:MERGE hint UPDATE INTO MDP_MATRIX

EP_LOAD_ITEMS

The EP_LOAD_ITEMS procedure is the main method by which items are loaded into Demantra internal tables. The procedure validates item hierarchy compliance and uploads all item dimension information into internal tables.

The following parameters can be used with the EP_LOAD_ITEMS procedure:

Ep_Load_ItemsUseParallelDML
Description If you run DML statements, any objects with a parallel degree configured will be run in parallel. Individual parallel hints setting will supersede this setting.
Values  
Default Value FALSE
Ep_Load_ItemsUseParallel
Description Set this parameter to FALSE when you do not want to use parallel hints in the EP_LOAD_ITEMS script.This parameter should be set to FALSE if your database has limited resources.
Values TRUE - EP_LOAD_ITEMS will use parallel hints. FALSE - EP_LOAD_ITEMS does will not use parallel hints.
Default Value TRUE
Ep_Load_ItemsUseOneCommit
Description Set this parameter to FALSE if your database is relatively small and has smaller rollback segments.If your database is powerful and thus sufficient resources are available, then set this parameter to TRUE.
Values TRUE - EP_LOAD_ITEMS executes only one commit.FALSE - EP_LOAD_ITEMS may execute more than one commit.
Default Value FALSE
DBHintEp_Load_ItemsMergeMDP
Description Hint for sub-select in merge statement with MDP_MATRIX. Used in the same statement with hint DBHintEp_Load_ItemsMergeMDP.The total degree of both hints should not exceed number of database CPUs.
Values ---
Default Value + parallel (a4)
Details MERGE INTO mdp_matrix (SELECT hint )
Ep_Load_ItemsDisableEnableMDPIndexes
Description This parameter disables indexes before performing the update on MDP_MATRIX and then rebuilds them when the update is complete.This parameter should be used only if the customer data set is very large and rebuilding indexes is faster than updates with indexes enabled.Note: This parameter is not currently used.
Values TRUE - Indexes on columns updated in the MDP_MATRIX MERGE update are disabled before the update and are rebuilt after the update.FALSE - Indexes remain during the update.
Default Value FALSE
Details This parameter is not currently used.
Ep_Load_ItemsIndexRebuildDegree
Description If EP_LOAD_ITEMS rebuilds indexes, this parameter controls what parallel degree to use. The value of this parameter should not exceed the number of available CPUs.
Values ---
Default Value 4
Details This parameter is not currently used.

EP_LOAD_LOCATIONS

The EP_LOAD_LOCATIONS procedure is the main method by which locations are loaded into Demantra internal tables. The procedure validates location hierarchy compliance and uploads all Location Dimension information into internal tables.

The following parameters can be used with the EP_LOAD_LOCATIONS procedure:

Ep_Load_LocationsUseParallelDML
Description If you run DML statements, any objects with a parallel degree configured will be run in parallel. Individual parallel hints setting will supersede this setting.
Values TRUE - EP_LOAD_LOCATIONS should use PARALLEL DML on objects that are set as parallel. FALSE - EP_LOAD_LOCATIONS should not use PARALLEL DML on objects that are set as parallel.
Default Value FALSE
Ep_Load_LocationsUseParallel
Description Set this parameter to FALSE when you do not want to use parallel hints in the EP_LOAD_LOCATIONS script. Set this parameter to FALSE if your database has limited resources.
Values TRUE - EP_LOAD_LOCATIONS will use parallel hints. FALSE - EP_LOAD_LOCATIONS will not use parallel hints.
Default Value TRUE
Ep_Load_LocationsUseOneCommit
Description Set this parameter to FALSE if your database is relatively small and has smaller rollback segments. If your database is powerful and thus sufficient resources are available, then set this parameter to TRUE.
Values TRUE - EP_LOAD_LOCATIONS executes only one commit. FALSE - EP_LOAD_LOCATIONS may execute more than one commit.
Default Value FALSE
DBHintEp_Load_LocationsMergeMDP
Description Hint for merge statement with MDP_MATRIX. Used in the same statement with hint DBHintEp_Load_Locations_MergeMDP_GLOB. The total degree of both hints should not exceed number of database CPUs.
Values ---
Default Value + parallel (m4)
Details MERGE (hint) INTO mdp_matrix (SELECT)
DBHintEp_Load_LocationsMergeMDP_GLOB
Description Hint for sub-select in merge statement with MDP_MATRIX. Used in the same statement with hint DBHintEp_Load_LocationsMergeMDP.The total degree of both hints should not exceed number of database CPUs.
Values ---
Default Value + parallel (a4)
Details MERGE INTO mdp_matrix (SELECT hint)
Ep_Load_LocationsDisableEnableMDPIndexes
Description This parameter disables indexes before performing the update on MDP_MATRIX and then rebuilds them when the update is complete.This parameter should be used only if your data set is very large and rebuilding indexes is faster than updates with indexes enabled.Note: This parameter is not currently used.
Values TRUE - EP_LOAD_LOCATIONS disables indexes on columns updated in the MDP_MATRIX MERGE update.FALSE - EP_LOAD_LOCATIONS does not disable indexes on columns updated in the MDP_MATRIX MERGE update.
Default Value FALSE
Ep_Load_LocationsIndexRebuildDegree
Description If EP_LOAD_LOCATIONS rebuilds indexes, this parameter controls what parallel degree to use. The value of this parameter should not exceed the number of available CPUs.Note: This parameter is not currently used.
Values ---
Default Value 4

EP_LOAD_SALES

The EP_LOAD_SALES procedure loads lowest level time-dependant information into the Demantra SALES_DATA table. This information includes historical data as well as other time-varying information such as price, booking, and shipments.

The following parameters can be used with the EP_LOAD_SALES procedure.

DBHintEp_Load_SalesUseParallelDML
Description If you run DML statements, any objects with a parallel degree configured will be run in parallel.Individual parallel hints setting will supersede this setting.
Values TRUE - LOAD_MDP_LEVEL will use PARALLEL DML on objects that are set as parallel.FALSE - LOAD_MDP_LEVEL will not use PARALLEL DML on objects that are set as parallel.
Default Value FALSE
DBHintEp_Load_SalesUseParallel
Description Set this parameter to FALSE when you do not want to use parallel hints in the EP_LOAD_SALES script.Should be set to FALSE when database resources are limited.
Values TRUE - EP_LOAD_SALES will use PARALLEL hints. FALSE - EP_LOAD_SALES will not use PARALLEL hints.
Default Value TRUE
DBHintEp_Load_SalesInsertErr
Description When checking data for errors. EP_LOAD_SALES will send invalid rows to error tables.This parameter enables hints on the SELECT statement to determine if there is an error.If loading very large source tables, providing a hint is recommended.
Values ---
Default Value + parallel (@T_SRC_SALES@ 4) full(@T_SRC_SALES@)
Details Example:INSERT INTO ... SELECT hint ... MINUS SELECT hint ... Note: Leave the token @T_SRC_SALES@ to be used for the real T_SRC sales table.
DBHintEp_Load_SalesInsertLd
Description Use this parameter when data from a staging table is aggregated to match internal time resolution. The hint defines the degree used during insert for aggregation.
Values ---
Default Value + parallel (@T_SRC_SALES@ 4)
Details Example Usage: INSERT EP_(t_src_sales)_LD... . This is the insert statement from the T_SRC_SALES table to the EP_T_SRC_SALES_LD table. Note: Leave the token @T_SRC_SALES@ to be used for the real T_SRC sales table.
DBHintEp_Load_SalesMergeMDP_LA
Description When inserting information into MDP_MATRIX_LOAD_ASSIST, this hint defines the degree used in the subselect statement.
Values ---
Default Value + parallel (@T_SRC_SALES_LD@ 4) full (@T_SRC_SALES_LD@)
Details Example Usage: MERGE INTO mdp_load_assist USING (SELECT hint ... FROM EP_ (t_src_sales)LD ....Note: Leave the token @T_SRC_SALES_LD@ to be used for the real T_SRC Load sales table,
DBHintEp_Load_SalesMergeSALES_DATA
Description When merging data into SALES_DATA table, this hint defines the degree used in the sub-select from intermediate data table.
Values ---
Default Value + parallel (@T_SRC_SALES_LD@ 4) full (@T_SRC_SALES_LD@)
Details Example:MERGE INTO SALES_DATA USING (SELECT hint ... FROM EP_ (t_src_sales)LD ....Note: Leave the token @T_SRC_SALES_LD@ to be used for the real T_SRC Load sales table.
Ep_Load_Sales_IgnoreNullActualQty
Description This parameter is used when inserting a row into the MDP_MATRIX table based on historical demand records.Set this parameter to FALSE if you are loading all rows in sales history. Set this parameter to True if you want to ignore rows where historical demand is null.Setting of FALSE is typically faster.
Values TRUE -Ignore/do not process for NULL values.FALSE - Process NULL values.
Default Value FALSE
Details ---
Ep_Load_Sales_MDP_LOAD_ASSIST_GatherStatsIfNoStats
Description Gathering statistics can be very slow in large environments.Initially, you would want to gather statistics but subsequently you may not want to gather statistics to improve performance. Parameter controls whether statistics are gathered on the MDP_LOAD_ASSIST table. When set to FALSE, statistics are always gathered. When set to TRUE statistics are gathered only if none exist.
Values TRUE - Gather statistics ONLY if MDP_LOAD_ASSIST has no table statistics.FALSE - Always gather statistics for MDP_LOAD_ASSIST.
Default Value FALSE
Details ---
Ep_Load_Sales_MDP_LOAD_ASSIST_GatherStats_1
Description Gather statistics for MDP_LOAD_ASSIST. Gathering executed first merge into MDP_LOAD_ASSIST.
Values TRUE - Gather statistics after the first merge into MDP_LOAD_ASSIST if no statistics are available.FALSE - Always gather statistics for MDP_LOAD_ASSIST after the first merge.
Default Value TRUE
Ep_Load_Sales_MDP_LOAD_ASSIST_GatherStats_2
Description Gather statistics for MDP_LOAD_ASSIST. Will be executed after second merge into MDP_LOAD_ASSIST.
Values TRUE - Gather statistics after the second merge into MDP_LOAD_ASSIST if no statistics are available.FALSE - Always gather statistics for MDP_LOAD_ASSIST after the second merge.
Default Value TRUE
Ep_Load_Sales_MDP_LOAD_ASSIST_GatherStats_3
Description Gather statistics for MDP_LOAD_ASSIST. Will be executed later in code, after delete from MDP_LOAD_ASSIST.This parameter will not be used if delete duplicates is not used (see Ep_Load_Sales_MDP_LOAD_ASSIST_DelDuplicates ).
Values TRUE - Gather statistics after deleting duplicates from MDP_LOAD_ASSIST if no statistics are available.FALSE - Always gather statistics for MDP_LOAD_ASSIST after deleting duplicates.
Default Value TRUE
Ep_Load_Sales_MDP_LOAD_ASSIST_DelDuplicates
Description Controls whether MDP_LOAD_ASSIST deletes any duplicates found in MDP_LOAD_ASSIST.Should be enabled if rows frequently are added to MDP_LOAD_ASSIST from a variety of sources.
Values TRUE - Delete duplicates from MDP_LOAD_ASSIST.FALSE - Do not delete duplicates from MDP_LOAD_ASSIST.
Default Value TRUE
Ep_Load_Sales_Run_CHANGE_IS_FICTIVE
Description Controls whether the procedure CHANGE_IS_FICTIVE is executed.This parameter must be set to TRUE if you are using Members Management or Chaining.
Values TRUE - Run CHANGE_IS_FICTIVE.FALSE - Do not run CHANGE_IS_FICTIVE.
Default Value TRUE
Ep_Load_Sales_SALES_DATA_Merge_InOneMerge
Description Controls whether rows are inserted into SALES_DATA from staging table in one MERGE or using a loop.Should be set to FALSE for smaller environments, with smaller database and rollback settings.For more powerful environments, setting this parameter to TRUE will improve performance.
Values TRUE - Use a single MERGE into SALES_DATA.FALSE - Merge is run in a location level loop.
Default Value FALSE
Ep_Load_Sales_SALES_DATA_Merge_LoopControl
Description If Ep_Load_Sales_SALES_DATA_Merge_InOneMerge is set to FALSE, then this level will define the commit points. The name of a suitable T_SRC_SALES_TMPL location column should be entered as an input.If left null, the generated default is the one of the first Location level columns available. Level chosen should have an average number of combinations matching desired commit point.
Values ---
Default Value ---

EXECUTE_PROFILES

Executes all the active rolling data profiles in the system. These are defined through the Business Modeler and are stored in the rolling_profiles table. A profile is active if it is selected in the Configure Rolling Session dialog box.

For each active profile, Business Modeler copies the source data into the target series. Data for any given time bucket is copied into the same time bucket in the target series.

The profiles are executed in the order in which they are listed in the Configure Rolling Session dialog box.

EXPOSE_PROMOTIONS

Iterates through the promotions listed in the promotion table, checks the status of each (the status field), and does the following:

For details, see “Configuring Promotion Effectiveness”.

INSERT_UNITS

INSERT_UNITS is the mechanism by which future rows are inserted into the SALES_DATA table. Before each engine task is executed, all combinations belonging to the task which will receive a forecast are evaluated and future rows are inserted where appropriate. Ensuring the appropriate rows are available enables the engine output to be written quickly and efficiently.

The Analytical Engine calls this procedure at the start of an engine run. For performance reasons, Insert_Units automatically runs as a distributed process. No setup is required.

This procedure is controlled by the RunInsertUnits parameter and can do several things, depending on the value of that parameter:

Makes sure the engine has rows to write into when generating the forecast. In particular, for all non-dead combinations, this procedure does the following:

RunInsertUnits and lead are engine parameters; see “Engine Parameters”.

The following parameters can be used with both the INSERT_UNITS and the DYN_INSERT_UNITS_BRANCH_ID procedures:

iu_do_commits
Description Should be set to TRUE for smaller databases or those with limited resources and smaller rollback segments. For larger databases with sufficient resources, set to FALSE.
Values TRUE – The EP_LOAD procedure will do commits as needed.FALSE – Use only one commit per run of a DYN_INSERT_UNITS_BRANCH_ID procedure.
Default Value TRUE
ep_load_do_commits
Description Used with the EP_LOAD_SALES procedure. Defines whether the procedure will commit as needed or wait until the entire process is complete. When DB resources may be limited, set this parameter to False.
Values TRUE - EP_LOAD will use the commit control and issue commits per n transitions.(Where n = SYS_PARAMS setting max_records_for_commit) FALSE - Use only one commit should be used per ep_load procedure.
Default Value TRUE

MANUALS_INS

Updates all the appropriate database tables after a user makes a change in a worksheet.

Note that the update_dead_comb parameter controls whether this procedure considers dead combinations.

You use this procedure only if you are using the desktop product (Demand Planner and Demand Replenisher) rather than the Web products. The Web products (Demand Planner Web, Promotion Effectiveness, and Settlement Management) use a Java-based mechanism to update the same tables.

update_dead_comb is an engine parameter; “Engine Parameters”.

MANUALS_INS_INTEGRATION

Updates all the appropriate database tables after data has been imported. Make sure you run this procedure after running an import integration interface.

MANUALS_INS_RECOVERY

Performs a recovery if MANUALS_INS or MANUALS_POPULATE_INS has failed. This procedure retrieves the temporary records that were written to the update_batch_trai_err and update_batch_values_err tables and completes the processing.

MDP_ADD

The MDP_ADD procedure is the main method by which Item/Location combinations are created in Demantra. Combinations are created and maintained based on Item/Location combinations existing in the SALES_DATA table. MDP_ADD also populates and maintains hierarchy information which is stored on MDP_MATRIX and executes the PROPORT procedure.

This procedure is run automatically when needed. It is responsible for maintaining the mdp_matrix table.

If the Analytical Engine fails with an error (“node not found in map”), you can correct the error by setting the align_sales_data_levels_in_loading parameter to true and then manually running the MDP_ADD procedure.

Depending on the setting of the RunProportInMdp_add parameter, this procedure may or may not call the proport mechanism when it runs.

The following parameters can be used with the MDP_ADD procedure:

Mdp_AddUpdateIs_Fictive
Description Defines whether the Is_fictive column is to be maintained.Is_fictive is used only in Chaining and Members Management. If you are using Chaining and Members Management, this parameter should be set to TRUE. If you are not using these features, performance may improve by setting this parameter to FALSE.
Values TRUE - MDP_ADD should update IS_FICTIVE. FALSE - MDP_ADD should not update IS_FICTIVE.
Default Value TRUE
Mdp_AddUpdateIs_Linked
Description Defines whether the Is_linked column is to be maintained.Is_fictive is used only in Chaining and Members Management. If you are using Chaining and Members Management, this parameter should be set to TRUE. If you are not using these features, performance may improve by setting this parameter to FALSE.
Values TRUE - MDP_ADD should update IS_LINKED. FALSE - MDP_ADD should not update IS_LINKED.
Default Value TRUE
Mdp_AddDeleteUnlinkedMdp_Matrix
Description This parameter controls whether MDP_MATRIX combinations not found in historical data tables are removed from the matrix.Setting depends on functionality. In large implementations substantial saving can be achieved by setting this parameter to FALSE.
Values TRUE - MDP_ADD should DELETE MDP_MATRIX rows not linked with SALES_DATA. In a PE schema, the delete also includes rows not linked with PROMOTION_DATA.FALSE - MDP_ADD should not DELETE MDP_MATRIX rows not linked with SALES_DATA.
Default Value FALSE
DBHintMdp_AddUseParallelDML
Description If you run DML statements, any objects with a parallel degree configured will be run in parallel.Individual parallel hints setting will supersede this setting.
Values TRUE - Use PARALLEL DML on objects that are set as parallel.FALSE - Do not use PARALLEL DML on objects that are set as parallel.
Default Value FALSE
DBHintMdp_AddUseParallel
Description Set this parameter to FALSE if you want to use parallel hints in the MDP_ADD script. This parameter should be set to FALSE when DB resources may be limited.
Values TRUE - EP_LOAD_ITEMS will use parallel hints.FALSE - EP_LOAD_ITEMS will not use parallel hints.
Default Value TRUE
DBHintMdp_AddInsert
Description Controls the degree used during the MDP_ADD insert statement when inserting rows into MDP_MATRIX. Used in the same statement as hint DBHintMdp_AddInsertSelect .The combined value of both parameters should not exceed the number of available CPUs.
Values + parallel(mdp_matrix 4) append
Default Value ---
Details INSERT hint INTO mdp_matrix
DBHintMdp_AddInsertSelect
Description Controls the degree used during the internal select of the MDP_ADD insert statement when inserting rows into MDP_MATRIX. Used in the same statement as hint DBHintMdp_AddInsert.The combined value of both parameters should not exceed the number of available CPUs.
Values ---
Default Value + parallel (@TBL_NAME@ 2) parallel (location 2) parallel (items 2)
Details INSERT INTO mdp_matrix SELECT hint.Note: Leave the token @TBL_NAME@ unchanged as it is to be used for the real table, usually MDP_LOAD_ASSIST.
DBHintMdp_AddMdpInsInMdpUseIn
Description If this parameter is set to TRUE, the MDP_ADD procedure checks if a row already exists before inserting to MDP_MATRIX.This parameter also controls whether the statement uses IN or NOT EXISTS.If set to TRUE the statement uses IN; otherwise it uses NOT EXISTS.
Values ---
Default Value TRUE
Details The default setting (TRUE) was chosen for backwards compatibility. However, setting this parameter to FALSE may improve performance.
DBHintMdp_AddMdpInsInTbl
Description SQL hint for inserting into MDP_MATRIX when choosing the IN mechanism via DBHintMdp_AddMdpInsInMdpUseIn. Used with hint DBHintMdp_AddMdpInsInMdp.The combined value of both parameters should not exceed the number of available CPUs.
Values TRUE - EP_LOAD_LOCATIONS should use PARALLEL DML on objects that are set as parallel.FALSE - EP_LOAD_LOCATIONS should use PARALLEL DML on objects that are set as parallel.
Default Value + parallel (a 2 )
Details INSERT INTO mdp_matrix SELECT ... WHERE ... IN (SELECT hint mdp_load_assist ...)
DBHintMdp_AddMdpInsInMdp
Description Controls minus sub-select of insert into MDP_MATRIX statement when choosing the IN mechanism. Used with DBHintMdp_AddMdpInsInTbl.The combined value of both parameters should not exceed the number of available CPUs.
Values ---
Default Value + parallel (b 2)
Details INSERT into mdp_matrix SELECT ... WHERE ... IN (SELECT mdp_load_assist MINUS SELECT hint mdp_matrix)
DBHintMdp_AddMdpCount
Description SQL hint on select count from MDP. This hint should be used in environments that have a large amount of data.This parameter should not be set to a value that exceeds the number of available CPUs.
Values ---
Default Value + full (MDP_MATRIX) parallel (MDP_MATRIX 4)
Details SELECT hint COUNT (*) FROM mdp_matrix
DBHintMdp_AddUpdateIs_Fictive0MDP
Description If updating Is_fictive, set degree parallel when updating MDP_MATRIX IS_FICTIVE value to 0.If you are not using Is_fictive, then this parameter is not used.
Values ---
Default Value ---
Details UPDATE hint mdp_matrix SET is_fictive =...
DBHintMdp_AddUpdateIs_Fictive0SD
Description This parameter is used in the subselect for updating Is_fictive value in MDP_MATRIX to 0.The degree set for this parameter, combined with DBHintMdp_AddUpdateIs_Fictive0MDP, should not exceed the number of available CPUs.
Values ---
Default Value + parallel(s 2 )
Details UPDATE mdp_matrix SET is_fictive = 0 EXISTS (SELECT hint FROM sales_data ...) AND is_fictive = 2
DBHintMdp_AddUpdateIs_Fictive2SD
Description Used in the subselect for updating Is_fictive value in MDP_MATRIX to 0.The degree set in this parameter combined with DBHintMdp_AddUpdateIs_Fictive0MDP should not exceed the number of available CPUs.
Values ---
Default Value + parallel(s 2 )
Details UPDATE mdp_matrix SET is_fictive = 2 NOT EXISTS (SELECT hint FROM sales_data ...) AND is_fictive = 0
DBHintMdp_AddDeleteMdp
Description If deleting MDP_MATRIX rows, use this parameter to set the degree used in delete.Used together with hints DBHintMdp_AddDeleteMdpNotInSD and DBHintMdp_AddDeleteMdpNotInPD. Total values of hints should not exceed number of available CPUs.
Values ---
Default Value + parallel(s 2)
DBHintMdp_AddDeleteMdpNotInSD
Description Hint used in the sub-select of delete population when viewing SALES_DATA.Used together with hints DBHintMdp_AddDeleteMdp and DBHintMdp_AddDeleteMdpNotInPD. Total values of hints should not exceed number of available CPUs.
Values ---
Default Value + parallel(s 2)
Details DELETE mdp_matrix WHERE NOT EXISTS (SELECT hint FROM SALES_DATA s...))
DBHintMdp_AddDeleteMdpNotInPD
Description Hint on the subselect of delete population when viewing promotion_data. Only used in environments that support promotions.Used together with hints DBHintMdp_AddDeleteMdp and DBHintMdp_AddDeleteMdpNotInSD. The total value of hints should not exceed the number of available CPUs
Values ---
Default Value + parallel (p 2)
Details DELETE mdp_matrix WHERE NOT EXISTS (SELECT ... SALES_DATA s) AND NOT EXISTS (SELECT hint PROMOTION_DATA s))
DBHintMdp_AddUseMdpCacheMerge
Description When updating from_date and until_date in MDP_MATRIX, the process be done via a single merge or a cursor loop.The Merge statement should be faster if there is a large amount of data with sufficient database capacity.
Values TRUE - Use the MERGE update for the MDP_MATRIX cache columns - FROM_DATE and UNTIL_DATE.FALSE - Use a cursor loop.
Default Value TRUE

POP_ALL_MATCH_PROPOSAL

Only for DSM. This procedure iterates through all settlements (except for off-invoice settlements), finds promotions that meet all the match criteria, and writes a record into the proposed_match table for each match.

This procedure performs the following comparisons, which are controlled by parameters:

POP_OI_MATCH_PROPOSAL

Only for DSM. This procedure iterates through all off-invoice settlements, finds promotions that meet all the match criteria, and writes a record into the proposed_match table for each match.

This procedure performs the following comparisons, which are controlled by parameters:

PRE_LOGON

Sets the database date and time formats.

Many other predefined procedures automatically call this procedure.

REBUILD_INDEXES

Oracle only. Rebuilds table indexes, a necessary maintenance task for the database.

Note: This procedure requires additional space (equal to the current tablespace) and can take a long time.

REBUILD_SCHEMA

Rebuilds all tables, a necessary maintenance task for Oracle databases.

Note: This procedure requires additional space (equal to the current tablespace) and can take a long time.

REBUILD_TABLES

Oracle only. Rebuilds the sales_data and mdp_matrix tables, a necessary maintenance task for Oracle databases.

Note: This procedure requires additional space (equal to the current tablespace) and can take a long time.

Arguments

This procedure has the following optional positional arguments:

REPLACE_APOSTROPHE_LEVELS

Iterates through the level tables and replaces any apostrophes in the column names with underscore characters.

SCHEDULED_CLEANUP_TASKS

Runs the Analyze Schema, Drop Temp Tables, Clean Log Tables, and Rebuild Tables workflows. By default this procedure runs once a week, on Saturdays.

UPGRADE_TO_SHAPE_MODELLING

Creates samples for activity shape modeling. Specifically this procedure does the following:

See “About Activity Shape Modeling”.