---
title: "SQL-003: clsAppError.InsertSQL"
summary: Inserts a new application error log row into App_Error.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-07-24
library: SAIF.Application.LogView
reference_type: package
---

# SQL-003: clsAppError.InsertSQL

This insert statement writes one application error row to `NetFramework.dbo.App_Error`. It captures application name, timestamp, environment, machine/page context, source, state information, error text, and user name before the identity value is read back by [SQL-001](SQL-001-saif-application-logview.md).

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-003 |
| **Operation type** | Create |
| **Execution method** | Inline |
| **Database** | SQL Server |
| **Schema** | `NetFramework.dbo` |
| **Command type** | Text |
| **Business object** | `clsAppError` |
| **Criteria property** | `InsertSQL` |
| **Lifecycle method** | `BeforeInsert` |

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `@App_Name` | Input | `String` | 50 | Application name from the error payload or explicit overload argument. |
| `@Error_Date` | Input | `DateTime` | N/A | Error timestamp. |
| `@Environment` | Input | `String` | 50 | Runtime environment name. |
| `@Machine_Name` | Input | `String` | 50 | Machine or host name that logged the error. |
| `@Page_Name` | Input | `String` | 50 | Page or request context name. |
| `@Error_Source` | Input | `String` | 50 | Exception source identifier. |
| `@State_Info` | Input | `String` | `StateInfo.Length` | Serialized state or context text. |
| `@Error_Info` | Input | `String` | `ErrorInfo.Length` | Detailed error text. |
| `@User_Name` | Input | `String` | 50 | User name associated with the error event. |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [App_Error](../database-tables.md#app_error) | INSERT | `App_Name`, `Error_Date`, `Environment`, `Machine_Name`, `Page_Name`, `Error_Source`, `State_Info`, `Error_Info`, `User_Name` |

## Sample SQL

```sql
INSERT INTO NetFramework.dbo.App_Error
           (App_Name
           ,Error_Date
           ,Environment
           ,Machine_Name
           ,Page_Name
           ,Error_Source
           ,State_Info
           ,Error_Info
           ,User_Name
           )
     VALUES
           (@App_Name
           ,@Error_Date
           ,@Environment
           ,@Machine_Name
           ,@Page_Name
           ,@Error_Source
           ,@State_Info
           ,@Error_Info
           ,@User_Name
           )
```

## Operations and processes
- [Create a new application error log entry from struct](../operations/error-logging.md)
- [Create a new application error log entry from discrete parameters](../operations/error-logging.md)

## Business rules
- [BR-006: Inserts must affect exactly one row](../business-rules.md#br-006-inserts-must-affect-exactly-one-row)

## Sources
- `Application\SAIF.Application.LogView\clsAppError.vb`

