---
title: "SQL-004: Delete context rows"
summary: Deletes all context rows for an application/session pair, used both to clear prior rows before a save and to consume rows after a retrieve.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-08-17
library: SAIF.Presentation.Web.MVC
reference_type: package
---

# SQL-004: Delete context rows

Removes every context row for a given application and session. `clsContext.SaveContext` calls this first to make the subsequent insert set ([SQL-001](SQL-001-insert-context-row.md)) a full replace rather than a merge; `clsContext.RetrieveContext` calls it immediately after reading rows ([SQL-002](SQL-002-retrieve-context-rows.md)) so a cross-application hand-off is consumed exactly once.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-004 |
| **Operation type** | Delete |
| **Execution method** | Inline SQL (VB `& _` string concatenation), `CommandType.Text`, `ExecuteNonQuery` |
| **Database** | SQL Server |
| **Schema** | `[unqualified]`** |
| **Command type** | Text |
| **Business object** | `clsContext.clsContextRepository` |
| **Criteria property** | N/A — not a BOF `IBusinessCriteria` object; SQL is held in the private `clsSQL` helper class |
| **Lifecycle method** | `clsContextRepository.Delete` |

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `@AppName` | Input | `SqlDbType.VarChar` | 50 | Application whose rows are purged |
| `@SessionID` | Input | `SqlDbType.VarChar` | 50 | ASP.NET session ID |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [Context](../database-tables.md#context) | DELETE | `AppName`, `SessionID` |

## Sample SQL

```sql
-- Oracle-style DELETE without FROM; the target table is the identifier immediately following Delete
Delete Context
Where
  AppName = @AppName
  and SessionID = @SessionID
```

## Operations and processes
- [Persist context rows](../operations/persist-context-rows.md)
- [Retrieve and consume context rows](../operations/retrieve-context-rows.md)

## Business rules
- [BR-MVC-017: Cross-application context is consumed exactly once](../business-rules.md#br-mvc-017-cross-application-context-is-consumed-exactly-once)
- [BR-MVC-019: Context persistence targets database APPM under tag NETFRAMEWORK](../business-rules.md#br-mvc-019-context-persistence-targets-database-appm-under-tag-netframework)

> **Note:** Statements marked with `**` could not be confirmed; treat as unknown until verified.

## Sources
- SAIF.Presentation.Web.MVC/clsContext.vb
