Skip to content

Purge deleted tasks

Unlike the rest of the task lifecycle, purge is a standalone shared function on clsTaskCollection that bypasses the normal BOF CRUD save path entirely. It calls the Oracle Task_Purge procedure directly with a source code, category code, and a retention window in days, and Oracle deletes only rows that have already been soft-deleted and have aged past the threshold.

Field Value
Operation ID OP-TASK-03
Trigger Caller invokes clsTaskCollection.PurgeTasks(inDataPortalInfo, inTaskSourceCode, inTaskCategoryCode, inKeepDays)
Inputs IDataPortalInfo, task source code, task category code, keep-days retention value
Outputs Count of physically deleted rows
Primary components clsTaskCollection.PurgeTasks
Entry point Business\SAIF.Business.Tasks\clsTaskCollection.vb

Steps

  1. Caller invokes the shared purge function with a data-portal info, a task source code, a task category code, and a keep-days value (passed as a string).
  2. Build the portal request. The function creates a new portal request and data request, sets RequestType = Scalar, CommandType = StoredProcedure, and the SQL statement to PK82036_Task.Task_Purge.
  3. Bind parameters. intasksourcecode, intaskcategorycode, and inkeepdays are bound as input parameters; outdelrows is bound as a string output parameter.
  4. Execute the procedure. The request is processed through inDataPortalInfo.ProcessPortalRequest, which calls PK82036_Task.Task_Purge (SQL-015, TASK).
  5. The procedure deletes rows only where TASK_SOURCE_CODE, TASK_CATEGORY_CODE, and DELETE_FLAG = 'Y' all match the requested slice (BR-021).
  6. Within that slice, only rows where TRUNC(update_date) < TRUNC(SYSDATE - TO_NUMBER(inkeepdays)) are removed, so rows soft-deleted more recently than the keep-days threshold survive even though they match the source/category slice (BR-022).
  7. Return the deleted-row count. The function reads outdelrows, converts it to an integer, and returns it to the caller as the number of rows physically removed.

Process flow

flowchart TD
    Start([Caller invokes PurgeTasks<br>with source, category, keep-days]) --> Build[Build scalar stored-procedure<br>request: Task_Purge]
    Build --> Exec[Execute PK82036_Task.Task_Purge]
    Exec --> Filter[Oracle filters rows:<br>matching source AND category<br>AND DELETE_FLAG = 'Y']
    Filter --> Age{update_date older than<br>keep-days threshold?}
    Age -->|Yes| Delete[Physically delete row]
    Age -->|No| Keep([Row retained])
    Delete --> Count[Accumulate deleted-row count]
    Count --> Return([Return outdelrows to caller])

Failure and edge-case behavior

  • Purge only ever affects rows already marked DELETE_FLAG = 'Y' by the task record lifecycle's soft-delete step; an active row can never be physically removed by this operation regardless of age.
  • The retention comparison truncates both sides to whole days (TRUNC(update_date) vs. TRUNC(SYSDATE - keepdays)), so a row soft-deleted earlier the same calendar day as the threshold boundary is not purged until the next day rolls over.
  • inKeepDays is accepted and bound as a string rather than a numeric type; a non-numeric value would fail inside the Oracle TO_NUMBER conversion rather than being validated by this class before the call.*
  • This function does not go through the standard Save()/business-rule pipeline used by the rest of the lifecycle, so none of the field-level validation rules (category, source, priority, mail ID) apply to a purge request.

Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts.

Sources

  • Business\SAIF.Business.Tasks\clsTaskCollection.vb