ProcessDeleteTaskStatsData

Delete records from Taskstats table

Member of namespace

Maintenance Manager

Syntax

bool ProcessDeleteTaskStatsData ()

Parameters

deleteOrphanData
True deletes the records from TaskStats table which are orphan.Orphan records means those records in TaskStats table whose related data from the main tables are already deleted or does not exists.
station
Optional. If orphan data from TaskStats table to be deleted from specific station. In case nothing is provided then orphan records will be deleted from Taskstats table irrespective of station value.
taskOperator
Optional. If orphan data from TaskStats table to be deleted which belongs to specific task operator. In case nothing is provided then orphan records will be deleted from Taskstats table irrespective of Task Operator value.
job
Optional. If orphan data from TaskStats table to be deleted from specific task job for e.g Main Job. In case nothing is provided then orphan records will be deleted from Taskstats table irrespective of Job value.
Note: Parameters Station, TaskOperator and Job will be used as filter parameter only to get orphan records. These parameters will not be applied to fetch records which are not orphan.
Note: Prior to calling ProcessDeleteTaskStatsData (), you must call a filter condition. Refer the following example.
Example:

QuerySetBatchRange () and QuerySetJobID () specifically states a filter query.

QuerySetBatchRange (str="xxx",str="xxx")
QuerySetJobID (str="Main Job")
ProcessDeleteTaskStatsData (bool=true,str="",str="",str="Main Job")

Returns

True, if the data deleted successfully. Otherwise, False.

Level

Any level.

Details

This action can delete two types of Data from TaskStats table.
  1. Orphan Data - Orphan data here refers to that data which do not have reference data in main tables returned by Job monitor view. There is a possibility that batches from main tables gets deleted earlier and data left over in the Taskstats table.

    For example: ProcessDeleteBatchesEX action deletes the record from the main tables but not from the TaskStats table.

    Query parameters using set of query actions cannot be used here. Since the query actions works on Job Monitor table data, and orphan data cannot be fetch from Job Monitor table.

    Thus, action have the separate parameter list provided which can be used to delete the selected set of records.

  2. Non-Orphan Data - Non-Orphan data here refers to the data from Taskstats table which have reference data in main tables. There can be scenario where the Taskstats data needs to be deleted only or there can be a requirement where at the time of deleting batches using ProcessDeleteBatchesEX action, the data from the TaskStats table needs to be deleted along with.

    To set which all batches to be deleted from TaskStats table can be set using Query actions. Similar to ProcessDeleteBatchesEX action. One can use ProcessRunSqlQueryEx action to view the query formed and how many batches were fetched. To view the fetched batches please refer to LogWriteRecordSet action.

    For more details, please refer action ProcessRunSqlQueryEX.

Example 1:
TaskStats table have few Orphan records along with other records but user wants to delete all Orphan records only.
SetupOpenApplicationEX("TravelDocs", "", "TravelDocsAdm.mdb", "TravelDocsEng.mdb", "False", "", "", "1")
ProcessDeleteTaskStatsData(True,””,””,””)

The first parameter in the action is set to True which denotes, orphan records from Taskstats table is expected to be deleted. Rest of the optional parameters are not provided which denotes all orphan records, irrespective of any filter is expected to be deleted from the Taskstats table.

Example 2:

TaskStats table have few Orphan records along with other records and user wants to delete all Orphan records belongs to specific job.

SetupOpenApplicationEX("TravelDocs", "", "TravelDocsAdm.mdb", "TravelDocsEng.mdb", "False", "", "", "1")
ProcessDeleteTaskStatsData(True,””,””,”Main Job”)

The first parameter in the action is set to True which denotes, orphan records from Taskstats table is expected to be deleted but only those which belongs to Job ID Main Job.

Example 3:

TaskStats table have few Orphan records along with other records. User wants to delete all Orphan records if any along with specific non-orphan data.
SetupOpenApplicationEX("TravelDocs", "", "TravelDocsAdm.mdb", "TravelDocsEng.mdb", "False", "", "", "1")
 QuerySetJobID(“Main Job”)
QuerySetStation(“1)
QuerySetStatus(“Cancelled”)
ProcessDeleteTaskStatsData(True,””,””,”Navigator Job”)
By using above set of query actions along with ProcessDeleteTaskStatsData action, will provide facility to delete orphan data as well as the data of those batches filtered out thru Query actions. In this example, the action will first delete the orphan records belonging to Navigator Job from task stats table and then it will delete the data from Taskstats table for those batches where batch status have cancelled status, station is 1 and Job ID is Main Job.
Note: The parameters value passed in the action will not be used to filter out the batches in case of non-orphan data. Vice Versa, the parameter passed in Query actions will not be used in case of deleting orphan data.
Example 4
SetupOpenApplicationEX("TravelDocs", "", "TravelDocsAdm.mdb", "TravelDocsEng.mdb", "False", "", "", "1")
QuerySetJobID(“Main Job”)
QuerySetStation(“1)
QuerySetStatus(“Cancelled”)
ProcessDeleteBatchesEX()
ProcessDeleteTaskStatsData(False,””,””,””)

In this example ProcessDeleteBatchesEX action is called before ProcessDeleteTaskStatsData which means the ProcessDeleteBatchesEX action will delete the batches from the main tables. Thus, these batches corresponding data in TaskStats table will become orphan as no reference is available in database for them in main tables.

Calling action ProcessDeleteTaskStatsData with parameter False will not delete any data from TaskStats table for two reasons:-
  1. -by setting parameter as False the action is expected to not delete any orphan records.
  2. -there is no non-orphan records for the given set of query actions available in Database. As they are already deleted and has become orphan now.

Example 5

ProcessMaster is called after ProcessDeleteTaskStatsData.
 SetupOpenApplicationEX("TravelDocs", "", "TravelDocsAdm.mdb", "TravelDocsEng.mdb", "False", "", "", "1")
QuerySetJobID(“Main Job”)
QuerySetStation(“1)
QuerySetStatus(“Cancelled”)
ProcessDeleteTaskStatsData(True,””,””,””)
ProcessDeleteBatchesEX()

In this example, the action will first delete all the orphan records. Then it will query for non-orphan data on the basis of query actions and will delete data from TaskStats Table. Later, ProcessDeleteBatchesEX action will delete the batches from main tables.

To view the count of non-orphan batches targeted for deletion, one can use ProcessRunSqlQueryEX action. To view these batches use the action LogWriteRecordSet action.

To view the count of orphan records that are going to be deleted can be seen in rrs logs. To view which all batches are going to be deleted, one need to check directly in database using a query.