---
title: "pk82036_task stored procedure documentation"
summary: Analysis of Oracle package including business rules and operations.
status: draft
owner: SAIF
last_reviewed: 2026-07-24
source_schema: WCIS_DBA
source_name: pk82036_task
source_type: PACKAGE
oracle_status: found
library: SAIF.Business.Tasks
reference_type: package
---

# pk82036_task

## Overview

| Field | Value |
| --- | --- |
| **Schema** | `WCIS_DBA` |
| **Type** | Package |
| **Database** | `PROD` |
| **Calling libraries** | `SAIF.Business.Tasks` |
| **Calling classes** | `clsTask`, `clsTaskCollection` |

## Purpose

`pk82036_task` owns the Oracle persistence contract for the reusable SAIF task model. It returns a single task row through a REF CURSOR, inserts and updates `TASK` rows with audit/version behavior, implements soft delete, and purges aged rows that were previously soft-deleted.

## Procedures / Methods

### task_select

| Field | Value |
| --- | --- |
| **Returns** | `REF CURSOR` over one `TASK` row |
| **Called by** | `clsTask.BeforeRetrieve` |

**Description:** Retrieves the task row identified by `TASK_SEQ_NUM` and returns the full mapped task/context/audit column set through a cursor.

#### Parameters

| Parameter | Direction | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `taskseqnum` | IN | `task.task_seq_num%TYPE` | — | Target task sequence number. |
| `recordset` | IN OUT | `ref_cursor` | — | Cursor opened over the matching task row. |

### task_insert

| Field | Value |
| --- | --- |
| **Returns** | `NUMBER` row-count result |
| **Called by** | `clsTask.BeforeInsert` |

**Description:** Inserts a new `TASK` row, normalizes zero-valued claim and policy inputs to `NULL`, applies sequence-generated identity, and seeds audit/version columns.

#### Parameters

| Parameter | Direction | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `taskdate` | IN | `task.task_date%TYPE` | — | Due date for the new task. |
| `tasktext` | IN | `task.task_text%TYPE` | — | Task body text. |
| `taskuser` | IN | `task.task_user%TYPE` | — | Assignee mail ID. |
| `taskprioritycode` | IN | `task.task_priority_code%TYPE` | — | Priority code. |
| `taskcategorycode` | IN | `task.task_category_code%TYPE` | — | Category code. |
| `tasksourcecode` | IN | `task.task_source_code%TYPE` | — | Source system code. |
| `taskactioncode` | IN | `task.task_action_code%TYPE` | — | Action code. |
| `notepadflag` | IN | `task.notepad_flag%TYPE` | — | Notepad-required flag. |
| `deleteflag` | IN | `task.delete_flag%TYPE` | — | Caller-supplied delete flag; package inserts `'N'`. |
| `claimid` | IN | `task.claim_id%TYPE` | — | Claim identifier, with `0` normalized to `NULL`. |
| `policynum` | IN | `task.policy_num%TYPE` | — | Policy number, with `0` normalized to `NULL`. |
| `imageseqnum` | IN | `task.image_seq_num%TYPE` | — | Image sequence number. |
| `contextcode` | IN | `task.context_code%TYPE` | — | Context code value. |
| `contextkey` | IN | `task.context_key%TYPE` | — | Context key value. |
| `contextcategory` | IN | `task.context_category%TYPE` | — | Context category value. |
| `contexttext` | IN | `task.context_text%TYPE` | — | Context text value. |
| `contextdate` | IN | `task.context_date%TYPE` | — | Context date value. |
| `contextnum` | IN | `task.context_num%TYPE` | — | Context numeric value. |
| `createuser` | IN | `task.create_user%TYPE` | — | Audit create user. |
| `updateuser` | IN | `task.update_user%TYPE` | — | Initial update user. |
| `tasksecurity` | IN | `task.task_security%TYPE` | — | Security tag. |

### task_update

| Field | Value |
| --- | --- |
| **Returns** | `NUMBER` row-count result |
| **Called by** | `clsTask.BeforeUpdate` |

**Description:** Updates a mutable task row, requires the caller's current row version, stamps audit fields, and increments `UPDATE_SEQ_NUM`.

#### Parameters

| Parameter | Direction | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `taskseqnum` | IN | `task.task_seq_num%TYPE` | — | Target task sequence number. |
| `taskdate` | IN | `task.task_date%TYPE` | — | Updated due date. |
| `tasktext` | IN | `task.task_text%TYPE` | — | Updated task body text. |
| `taskuser` | IN | `task.task_user%TYPE` | — | Updated assignee. |
| `taskprioritycode` | IN | `task.task_priority_code%TYPE` | — | Updated priority code. |
| `taskcategorycode` | IN | `task.task_category_code%TYPE` | — | Updated category code. |
| `taskactioncode` | IN | `task.task_action_code%TYPE` | — | Updated action code. |
| `notepadflag` | IN | `task.notepad_flag%TYPE` | — | Updated notepad-required flag. |
| `deleteflag` | IN | `task.delete_flag%TYPE` | — | Current delete flag value. |
| `claimid` | IN | `task.claim_id%TYPE` | — | Claim identifier, with `0` normalized to `NULL`. |
| `policynum` | IN | `task.policy_num%TYPE` | — | Policy number, with `0` normalized to `NULL`. |
| `imageseqnum` | IN | `task.image_seq_num%TYPE` | — | Image sequence number. |
| `contextcode` | IN | `task.context_code%TYPE` | — | Context code value. |
| `contextkey` | IN | `task.context_key%TYPE` | — | Context key value. |
| `contextcategory` | IN | `task.context_category%TYPE` | — | Context category value. |
| `contexttext` | IN | `task.context_text%TYPE` | — | Context text value. |
| `contextdate` | IN | `task.context_date%TYPE` | — | Context date value. |
| `contextnum` | IN | `task.context_num%TYPE` | — | Context numeric value. |
| `updateuser` | IN | `task.update_user%TYPE` | — | Audit update user. |
| `updateseqnum` | IN | `task.update_seq_num%TYPE` | — | Optimistic-concurrency token. |
| `tasksecurity` | IN | `task.task_security%TYPE` | — | Security tag. |

### task_delete

| Field | Value |
| --- | --- |
| **Returns** | `NUMBER` row-count result |
| **Called by** | `clsTask.BeforeDelete` |

**Description:** Performs a soft delete by setting `DELETE_FLAG = 'Y'`, updating audit columns, and incrementing `UPDATE_SEQ_NUM` when the row version matches.

#### Parameters

| Parameter | Direction | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `taskseqnum` | IN | `task.task_seq_num%TYPE` | — | Target task sequence number. |
| `updateseqnum` | IN | `task.update_seq_num%TYPE` | — | Optimistic-concurrency token. |
| `updateuser` | IN | `task.update_user%TYPE` | — | Audit update user. |

### task_purge

| Field | Value |
| --- | --- |
| **Returns** | Deleted-row count through `outdelrows` |
| **Called by** | `clsTaskCollection.PurgeTasks` |

**Description:** Physically deletes previously soft-deleted `TASK` rows for one source/category pair when the row's update date is older than the keep-days retention threshold.

#### Parameters

| Parameter | Direction | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `intasksourcecode` | IN | `task.task_source_code%TYPE` | — | Source-system filter for the purge. |
| `intaskcategorycode` | IN | `task.task_category_code%TYPE` | — | Category filter for the purge. |
| `inkeepdays` | IN | `VARCHAR2` | — | Retention threshold expressed in days. |
| `outdelrows` | OUT | `VARCHAR2` | — | Deleted-row count returned to the caller. |

### Additional package members present in Oracle source

| Member | Kind | Description |
| --- | --- | --- |
| `selecttasks` | Procedure | Opens a caller-supplied SQL string as a `REF CURSOR`. |
| `task_insert` | Legacy procedure overload | Retains the pre-function insert signature noted in the in-source compatibility comment. |
| `task_update` | Legacy procedure overload | Retains the pre-function update signature noted in the in-source compatibility comment. |
| `task_delete` | Legacy procedure overload | Retains the pre-function delete signature noted in the in-source compatibility comment. |

## Business Rules

Rules extracted from this procedure's logic:

| Rule ID | Rule | Condition | Action |
| --- | --- | --- | --- |
| [BR-012](../business-rules.md#br-012-single-task-retrieval-is-keyed-only-by-task-sequence-number) | Single-task retrieval is keyed only by task sequence number. | `WHERE task.task_seq_num = taskseqnum` | Opens a REF CURSOR over the matching `TASK` row. |
| [BR-013](../business-rules.md#br-013-insert-normalizes-zero-claim-ids-to-null) | Zero claim IDs are normalized to `NULL` during insert. | `DECODE(claimid, 0, NULL, claimid)` in the insert values list | Prevents storing `0` in `TASK.CLAIM_ID`. |
| [BR-014](../business-rules.md#br-014-insert-normalizes-zero-policy-numbers-to-null) | Zero policy numbers are normalized to `NULL` during insert. | `DECODE(policynum, 0, NULL, policynum)` in the insert values list | Prevents storing `0` in `TASK.POLICY_NUM`. |
| [BR-015](../business-rules.md#br-015-new-tasks-start-active-and-versioned-from-zero) | New tasks start active and versioned from zero. | Insert body sets `DELETE_FLAG = 'N'`, `UPDATE_SEQ_NUM = 0`, `CREATE_DATE = SYSDATE`, `UPDATE_DATE = SYSDATE`, and `TASK_SEQ_NUM = TASK_SEQ.NEXTVAL` | Seeds identity and audit/version state. |
| [BR-016](../business-rules.md#br-016-task-update-requires-a-matching-optimistic-concurrency-token) | Updates require a matching optimistic-concurrency token. | `WHERE task_seq_num = taskseqnum AND update_seq_num = updateseqnum` | Rejects stale updates by returning `SQL%ROWCOUNT = 0`. |
| [BR-017](../business-rules.md#br-017-update-normalizes-zero-claim-and-policy-values-to-null) | Zero claim and policy values are normalized to `NULL` during update. | `DECODE(claimid, 0, NULL, claimid)` and `DECODE(policynum, 0, NULL, policynum)` | Preserves optional-relationship semantics. |
| [BR-018](../business-rules.md#br-018-successful-updates-always-advance-audit-and-version-fields) | Successful updates always advance audit/version fields. | Update body sets `UPDATE_DATE = SYSDATE`, `UPDATE_SEQ_NUM = updateseqnum + 1`, and `UPDATE_USER = updateuser` | Records the updater and increments the row version. |
| [BR-019](../business-rules.md#br-019-task-delete-is-implemented-as-a-soft-delete) | Delete is implemented as a soft delete. | Delete body sets `DELETE_FLAG = 'Y'` instead of issuing `DELETE FROM TASK` | Retains the row while marking it deleted. |
| [BR-020](../business-rules.md#br-020-soft-delete-requires-a-matching-optimistic-concurrency-token) | Soft delete requires a matching optimistic-concurrency token. | `WHERE task_seq_num = taskseqnum AND update_seq_num = updateseqnum` | Rejects stale deletes by returning `SQL%ROWCOUNT = 0`. |
| [BR-021](../business-rules.md#br-021-task-purge-is-limited-to-deleted-rows-in-the-requested-source-and-category-slice) | Physical purge is limited to already deleted rows in the requested source/category slice. | Purge `WHERE` clause requires matching source, category, and `DELETE_FLAG = 'Y'` | Prevents purge of active rows. |
| [BR-022](../business-rules.md#br-022-task-purge-retention-is-enforced-by-whole-day-age) | Purge retention is enforced by whole-day age. | `TRUNC(update_date) < TRUNC(SYSDATE - TO_NUMBER(inkeepdays))` | Deletes only rows older than the keep-days threshold. |

> These rules are documented in [Business rules](../business-rules.md). Newly introduced rules must be added to `business-rules.md` as part of the same writing task.

## Operations

Operations and processes implemented in this procedure:

| Operation | Description | Trigger |
| --- | --- | --- |
| Retrieve task row | Opens a cursor over one `TASK` row and returns the mapped columns. | `clsTask.BeforeRetrieve` |
| Insert task row | Inserts a new `TASK` row, applies audit defaults, and returns `SQL%ROWCOUNT`. | `clsTask.BeforeInsert` |
| Update task row | Updates mutable fields, stamps audit data, increments `UPDATE_SEQ_NUM`, and returns `SQL%ROWCOUNT`. | `clsTask.BeforeUpdate` |
| Soft-delete task row | Marks the row deleted and increments `UPDATE_SEQ_NUM` without removing the row. | `clsTask.BeforeDelete` |
| Purge deleted task rows | Physically deletes aged, already deleted rows and returns the deleted-row count. | `clsTaskCollection.PurgeTasks` |

> These operations are also listed in [Operations and processes](../operations-processes.md) with source reference back to this document.

## Source Code

<details>
<summary>PL/SQL package specification</summary>

```sql
PACKAGE pk82036_task
AS
   TYPE ref_cursor IS REF CURSOR;

   PROCEDURE task_select(
      taskseqnum   IN       task.task_seq_num%TYPE
    , recordset    IN OUT   ref_cursor);

   FUNCTION task_insert(
      taskdate           IN   task.task_date%TYPE
    , tasktext           IN   task.task_text%TYPE
    , taskuser           IN   task.task_user%TYPE
    , taskprioritycode   IN   task.task_priority_code%TYPE
    , taskcategorycode   IN   task.task_category_code%TYPE
    , tasksourcecode     IN   task.task_source_code%TYPE
    , taskactioncode     IN   task.task_action_code%TYPE
    , notepadflag        IN   task.notepad_flag%TYPE
    , deleteflag         IN   task.delete_flag%TYPE
    , claimid            IN   task.claim_id%TYPE
    , policynum          IN   task.policy_num%TYPE
    , imageseqnum        IN   task.image_seq_num%TYPE
    , contextcode        IN   task.context_code%TYPE
    , contextkey         IN   task.context_key%TYPE
    , contextcategory    IN   task.context_category%TYPE
    , contexttext        IN   task.context_text%TYPE
    , contextdate        IN   task.context_date%TYPE
    , contextnum         IN   task.context_num%TYPE
    , createuser         IN   task.create_user%TYPE
    , updateuser         IN   task.update_user%TYPE
    , tasksecurity       IN   task.task_security%TYPE
	) RETURN NUMBER;

   FUNCTION task_update(
      taskseqnum         IN   task.task_seq_num%TYPE
    , taskdate           IN   task.task_date%TYPE
    , tasktext           IN   task.task_text%TYPE
    , taskuser           IN   task.task_user%TYPE
    , taskprioritycode   IN   task.task_priority_code%TYPE
    , taskcategorycode   IN   task.task_category_code%TYPE
    , taskactioncode     IN   task.task_action_code%TYPE
    , notepadflag        IN   task.notepad_flag%TYPE
    , deleteflag         IN   task.delete_flag%TYPE
    , claimid            IN   task.claim_id%TYPE
    , policynum          IN   task.policy_num%TYPE
    , imageseqnum        IN   task.image_seq_num%TYPE
    , contextcode        IN   task.context_code%TYPE
    , contextkey         IN   task.context_key%TYPE
    , contextcategory    IN   task.context_category%TYPE
    , contexttext        IN   task.context_text%TYPE
    , contextdate        IN   task.context_date%TYPE
    , contextnum         IN   task.context_num%TYPE
    , updateuser         IN   task.update_user%TYPE
    , updateseqnum       IN   task.update_seq_num%TYPE
    , tasksecurity       IN   task.task_security%TYPE
	) RETURN NUMBER;

   FUNCTION task_delete(
      taskseqnum     IN   task.task_seq_num%TYPE
    , updateseqnum   IN   task.update_seq_num%TYPE
    , updateuser     IN   task.update_user%TYPE
	) RETURN NUMBER;

   PROCEDURE selecttasks(
      taskselectsql   IN       VARCHAR2
    , recordset       IN OUT   ref_cursor);

   PROCEDURE task_purge(
      intasksourcecode     IN       task.task_source_code%TYPE
    , intaskcategorycode   IN       task.task_category_code%TYPE
    , inkeepdays           IN       VARCHAR2
    , outdelrows           OUT      VARCHAR2);

 -- REMOVE THESE AFTER ALL APPS are using the version of saifTasks created in August 2007.
   PROCEDURE task_insert(
      taskdate           IN   task.task_date%TYPE
    , tasktext           IN   task.task_text%TYPE
    , taskuser           IN   task.task_user%TYPE
    , taskprioritycode   IN   task.task_priority_code%TYPE
    , taskcategorycode   IN   task.task_category_code%TYPE
    , tasksourcecode     IN   task.task_source_code%TYPE
    , taskactioncode     IN   task.task_action_code%TYPE
    , notepadflag        IN   task.notepad_flag%TYPE
    , deleteflag         IN   task.delete_flag%TYPE
    , claimid            IN   task.claim_id%TYPE
    , policynum          IN   task.policy_num%TYPE
    , imageseqnum        IN   task.image_seq_num%TYPE
    , contextcode        IN   task.context_code%TYPE
    , contextkey         IN   task.context_key%TYPE
    , contextcategory    IN   task.context_category%TYPE
    , contexttext        IN   task.context_text%TYPE
    , contextdate        IN   task.context_date%TYPE
    , contextnum         IN   task.context_num%TYPE
    , createuser         IN   task.create_user%TYPE
    , updateuser         IN   task.update_user%TYPE
    , tasksecurity       IN   task.task_security%TYPE);

   PROCEDURE task_update(
      taskseqnum         IN   task.task_seq_num%TYPE
    , taskdate           IN   task.task_date%TYPE
    , tasktext           IN   task.task_text%TYPE
    , taskuser           IN   task.task_user%TYPE
    , taskprioritycode   IN   task.task_priority_code%TYPE
    , taskcategorycode   IN   task.task_category_code%TYPE
    , taskactioncode     IN   task.task_action_code%TYPE
    , notepadflag        IN   task.notepad_flag%TYPE
    , deleteflag         IN   task.delete_flag%TYPE
    , claimid            IN   task.claim_id%TYPE
    , policynum          IN   task.policy_num%TYPE
    , imageseqnum        IN   task.image_seq_num%TYPE
    , contextcode        IN   task.context_code%TYPE
    , contextkey         IN   task.context_key%TYPE
    , contextcategory    IN   task.context_category%TYPE
    , contexttext        IN   task.context_text%TYPE
    , contextdate        IN   task.context_date%TYPE
    , contextnum         IN   task.context_num%TYPE
    , updateuser         IN   task.update_user%TYPE
    , updateseqnum       IN   task.update_seq_num%TYPE
    , tasksecurity       IN   task.task_security%TYPE);

   PROCEDURE task_delete(
      taskseqnum     IN   task.task_seq_num%TYPE
    , updateseqnum   IN   task.update_seq_num%TYPE
    , updateuser     IN   task.update_user%TYPE);

END pk82036_task;
 /
```

</details>

<details>
<summary>PL/SQL package body</summary>

```sql
PACKAGE BODY pk82036_task
AS
   /********************************************
   ** MULTI_SELECT PROCEDURE FOR TABLE "TASK"
   ** DATE: 19-JUL-06 15:10:03
   *********************************************/
   PROCEDURE selecttasks (
      taskselectsql   IN       VARCHAR2,
      recordset       IN OUT   ref_cursor
   )
   IS
   BEGIN
      OPEN recordset FOR taskselectsql;
   END selecttasks;

   /********************************************
   ** SELECT PROCEDURE FOR TABLE "TASK"
   ** DATE: 19-JUL-06 15:10:03
   *********************************************/
   PROCEDURE task_select (
      taskseqnum   IN       task.task_seq_num%TYPE,
      recordset    IN OUT   ref_cursor
   )
   IS
   BEGIN
      OPEN recordset FOR
         SELECT task.claim_id AS claimid,
                task.context_category AS contextcategory,
                task.context_code AS contextcode,
                task.context_date AS contextdate,
                task.context_key AS contextkey,
                task.context_num AS contextnum,
                task.context_text AS contexttext,
                task.create_date AS createdate,
                task.create_user AS createuser,
                task.delete_flag AS deleteflag,
                task.image_seq_num AS imageseqnum,
                task.notepad_flag AS notepadflag,
                task.policy_num AS policynum,
                task.task_action_code AS taskactioncode,
                task.task_category_code AS taskcategorycode,
                task.task_date AS taskdate,
                task.task_priority_code AS taskprioritycode,
                task.task_security AS tasksecurity,
                task.task_seq_num AS taskseqnum,
                task.task_source_code AS tasksourcecode,
                task.task_text AS tasktext, task.task_user AS taskuser,
                task.update_date AS updatedate,
                task.update_seq_num AS updateseqnum,
                task.update_user AS updateuser
           FROM task
          WHERE task.task_seq_num = taskseqnum;
   END task_select;

   /********************************************
   ** INSERT FUNCTION FOR TABLE "TASK"
   ** DATE: 19-JUL-06 15:10:03
   *********************************************/
   FUNCTION task_insert (
      taskdate           IN   task.task_date%TYPE,
      tasktext           IN   task.task_text%TYPE,
      taskuser           IN   task.task_user%TYPE,
      taskprioritycode   IN   task.task_priority_code%TYPE,
      taskcategorycode   IN   task.task_category_code%TYPE,
      tasksourcecode     IN   task.task_source_code%TYPE,
      taskactioncode     IN   task.task_action_code%TYPE,
      notepadflag        IN   task.notepad_flag%TYPE,
      deleteflag         IN   task.delete_flag%TYPE,
      claimid            IN   task.claim_id%TYPE,
      policynum          IN   task.policy_num%TYPE,
      imageseqnum        IN   task.image_seq_num%TYPE,
      contextcode        IN   task.context_code%TYPE,
      contextkey         IN   task.context_key%TYPE,
      contextcategory    IN   task.context_category%TYPE,
      contexttext        IN   task.context_text%TYPE,
      contextdate        IN   task.context_date%TYPE,
      contextnum         IN   task.context_num%TYPE,
      createuser         IN   task.create_user%TYPE,
      updateuser         IN   task.update_user%TYPE,
      tasksecurity       IN   task.task_security%TYPE
   )
      RETURN NUMBER
   IS
   BEGIN
      -- Modified to force 0 claimid and policynum to null.
      -- A 0(zero) claimid or policynum does not make sense and is preventing
      -- RI on the table.

      INSERT INTO task
                  (claim_id, context_category, context_code, context_date,
                   context_key, context_num, context_text, create_date,
                   create_user, delete_flag, image_seq_num, notepad_flag,
                   policy_num, task_action_code, task_category_code,
                   task_date, task_priority_code, task_security,
                   task_seq_num, task_source_code, task_text, task_user,
                   update_date, update_seq_num, update_user
                  )
           VALUES (decode(claimid, 0, null,claimid), contextcategory, contextcode, contextdate,
                   contextkey, contextnum, contexttext, SYSDATE,
                   createuser, 'N', imageseqnum, notepadflag,
                   decode(policynum, 0, null,policynum), taskactioncode, taskcategorycode,
                   taskdate, taskprioritycode, tasksecurity,
                   task_seq.NEXTVAL, tasksourcecode, tasktext, taskuser,
                   SYSDATE, 0, updateuser
                  );

      RETURN SQL%ROWCOUNT;
   END task_insert;

   /********************************************
   ** UPDATE FUNCTION FOR TABLE "TASK"
   ** DATE: 19-JUL-06 15:10:03
   *********************************************/
   FUNCTION task_update (
      taskseqnum         IN   task.task_seq_num%TYPE,
      taskdate           IN   task.task_date%TYPE,
      tasktext           IN   task.task_text%TYPE,
      taskuser           IN   task.task_user%TYPE,
      taskprioritycode   IN   task.task_priority_code%TYPE,
      taskcategorycode   IN   task.task_category_code%TYPE,
      taskactioncode     IN   task.task_action_code%TYPE,
      notepadflag        IN   task.notepad_flag%TYPE,
      deleteflag         IN   task.delete_flag%TYPE,
      claimid            IN   task.claim_id%TYPE,
      policynum          IN   task.policy_num%TYPE,
      imageseqnum        IN   task.image_seq_num%TYPE,
      contextcode        IN   task.context_code%TYPE,
      contextkey         IN   task.context_key%TYPE,
      contextcategory    IN   task.context_category%TYPE,
      contexttext        IN   task.context_text%TYPE,
      contextdate        IN   task.context_date%TYPE,
      contextnum         IN   task.context_num%TYPE,
      updateuser         IN   task.update_user%TYPE,
      updateseqnum       IN   task.update_seq_num%TYPE,
      tasksecurity       IN   task.task_security%TYPE
   )
      RETURN NUMBER
   IS
   BEGIN
      -- Modified to force 0 claimid and policynum to null.
        -- A 0(zero) claimid or policynum does not make sense and is preventing
        -- RI on the table.

      UPDATE task
         SET claim_id = decode(claimid, 0, null,claimid),
             context_category = contextcategory,
             context_code = contextcode,
             context_date = contextdate,
             context_key = contextkey,
             context_num = contextnum,
             context_text = contexttext,
             delete_flag = deleteflag,
             image_seq_num = imageseqnum,
             notepad_flag = notepadflag,
             policy_num = decode(policynum, 0, null,policynum),
             task_action_code = taskactioncode,
             task_category_code = taskcategorycode,
             task_date = taskdate,
             task_priority_code = taskprioritycode,
             task_security = tasksecurity,
             task_text = tasktext,
             task_user = taskuser,
             update_date = SYSDATE,
             update_seq_num = updateseqnum + 1,
             update_user = updateuser
       WHERE task_seq_num = taskseqnum AND update_seq_num = updateseqnum;

      RETURN SQL%ROWCOUNT;
   END task_update;

   /********************************************
   ** DELETE FUNCTION FOR TABLE "TASK"
   ** DATE: 19-JUL-06 15:10:03
   *********************************************/
   FUNCTION task_delete (
      taskseqnum     IN   task.task_seq_num%TYPE,
      updateseqnum   IN   task.update_seq_num%TYPE,
      updateuser     IN   task.update_user%TYPE
   )
      RETURN NUMBER
   IS
   BEGIN
      UPDATE task
         SET delete_flag = 'Y',
             update_date = SYSDATE,
             update_seq_num = updateseqnum + 1,
             update_user = updateuser
       WHERE task_seq_num = taskseqnum AND update_seq_num = updateseqnum;

      RETURN SQL%ROWCOUNT;
   END task_delete;

   PROCEDURE task_purge (
      intasksourcecode     IN       task.task_source_code%TYPE,
      intaskcategorycode   IN       task.task_category_code%TYPE,
      inkeepdays           IN       VARCHAR2,
      outdelrows           OUT      VARCHAR2
   )
   AS
   BEGIN
      DELETE      task
            WHERE task_source_code = intasksourcecode
              AND task_category_code = intaskcategorycode
              AND delete_flag = 'Y'
              AND TRUNC (update_date) <
                                      TRUNC (SYSDATE - TO_NUMBER (inkeepdays));

      outdelrows := TO_CHAR (SQL%ROWCOUNT);
   END;

   -- delete the procedures after all apps are using the functions
   PROCEDURE task_insert (
      taskdate           IN   task.task_date%TYPE,
      tasktext           IN   task.task_text%TYPE,
      taskuser           IN   task.task_user%TYPE,
      taskprioritycode   IN   task.task_priority_code%TYPE,
      taskcategorycode   IN   task.task_category_code%TYPE,
      tasksourcecode     IN   task.task_source_code%TYPE,
      taskactioncode     IN   task.task_action_code%TYPE,
      notepadflag        IN   task.notepad_flag%TYPE,
      deleteflag         IN   task.delete_flag%TYPE,
      claimid            IN   task.claim_id%TYPE,
      policynum          IN   task.policy_num%TYPE,
      imageseqnum        IN   task.image_seq_num%TYPE,
      contextcode        IN   task.context_code%TYPE,
      contextkey         IN   task.context_key%TYPE,
      contextcategory    IN   task.context_category%TYPE,
      contexttext        IN   task.context_text%TYPE,
      contextdate        IN   task.context_date%TYPE,
      contextnum         IN   task.context_num%TYPE,
      createuser         IN   task.create_user%TYPE,
      updateuser         IN   task.update_user%TYPE,
      tasksecurity       IN   task.task_security%TYPE
   )
   IS
   BEGIN
     -- Modified to force 0 claimid and policynum to null.
      -- A 0(zero) claimid or policynum does not make sense and is preventing
      -- RI on the table.


      INSERT INTO task
                  (claim_id, context_category, context_code, context_date,
                   context_key, context_num, context_text, create_date,
                   create_user, delete_flag, image_seq_num, notepad_flag,
                   policy_num, task_action_code, task_category_code,
                   task_date, task_priority_code, task_security,
                   task_seq_num, task_source_code, task_text, task_user,
                   update_date, update_seq_num, update_user
                  )
           VALUES (decode(claimid, 0, null,claimid), contextcategory, contextcode, contextdate,
                   contextkey, contextnum, contexttext, SYSDATE,
                   createuser, 'N', imageseqnum, notepadflag,
                   decode(policynum, 0, null,policynum), taskactioncode, taskcategorycode,
                   taskdate, taskprioritycode, tasksecurity,
                   task_seq.NEXTVAL, tasksourcecode, tasktext, taskuser,
                   SYSDATE, 0, updateuser
                  );
   END task_insert;

   /********************************************
   ** UPDATE PROCEDURE FOR TABLE "TASK"
   ** DATE: 19-JUL-06 15:10:03
   *********************************************/
   PROCEDURE task_update (
      taskseqnum         IN   task.task_seq_num%TYPE,
      taskdate           IN   task.task_date%TYPE,
      tasktext           IN   task.task_text%TYPE,
      taskuser           IN   task.task_user%TYPE,
      taskprioritycode   IN   task.task_priority_code%TYPE,
      taskcategorycode   IN   task.task_category_code%TYPE,
      taskactioncode     IN   task.task_action_code%TYPE,
      notepadflag        IN   task.notepad_flag%TYPE,
      deleteflag         IN   task.delete_flag%TYPE,
      claimid            IN   task.claim_id%TYPE,
      policynum          IN   task.policy_num%TYPE,
      imageseqnum        IN   task.image_seq_num%TYPE,
      contextcode        IN   task.context_code%TYPE,
      contextkey         IN   task.context_key%TYPE,
      contextcategory    IN   task.context_category%TYPE,
      contexttext        IN   task.context_text%TYPE,
      contextdate        IN   task.context_date%TYPE,
      contextnum         IN   task.context_num%TYPE,
      updateuser         IN   task.update_user%TYPE,
      updateseqnum       IN   task.update_seq_num%TYPE,
      tasksecurity       IN   task.task_security%TYPE
   )
   IS
   BEGIN
  -- Modified to force 0 claimid and policynum to null.
      -- A 0(zero) claimid or policynum does not make sense and is preventing
      -- RI on the table.

      UPDATE task
         SET claim_id = decode(claimid, 0, null,claimid),
             context_category = contextcategory,
             context_code = contextcode,
             context_date = contextdate,
             context_key = contextkey,
             context_num = contextnum,
             context_text = contexttext,
             delete_flag = deleteflag,
             image_seq_num = imageseqnum,
             notepad_flag = notepadflag,
             policy_num = decode(policynum, 0, null,policynum),
             task_action_code = taskactioncode,
             task_category_code = taskcategorycode,
             task_date = taskdate,
             task_priority_code = taskprioritycode,
             task_security = tasksecurity,
             task_text = tasktext,
             task_user = taskuser,
             update_date = SYSDATE,
             update_seq_num = updateseqnum + 1,
             update_user = updateuser
       WHERE task_seq_num = taskseqnum AND update_seq_num = updateseqnum;
   END task_update;

   /********************************************
   ** DELETE PROCEDURE FOR TABLE "TASK"
   ** DATE: 19-JUL-06 15:10:03
   *********************************************/
   PROCEDURE task_delete (
      taskseqnum     IN   task.task_seq_num%TYPE,
      updateseqnum   IN   task.update_seq_num%TYPE,
      updateuser     IN   task.update_user%TYPE
   )
   IS
   BEGIN
      UPDATE task
         SET delete_flag = 'Y',
             update_date = SYSDATE,
             update_seq_num = updateseqnum + 1,
             update_user = updateuser
       WHERE task_seq_num = taskseqnum AND update_seq_num = updateseqnum;
   END task_delete;
END pk82036_task;
```

</details>

## Related documentation
- [Index](../index.md)
- [Overview](../overview.md)
- [Architecture](../architecture.md)
- [Dependencies](../dependencies.md)
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [Database tables](../database-tables.md)
- [SQL catalog](../sql/index.md)
- [Procedures](index.md)
- [API reference](../api/index.md)

## Sources
- `Business\SAIF.Business.Tasks\clsTask.vb`
- `Business\SAIF.Business.Tasks\clsTaskCollection.vb`


