---
title: "SQL-041: Load auditor by AD user and vendor; fallback by vendor"
summary: Resolves a premium auditor ID for an AD user and vendor number, with a vendor-only fallback.
status: draft
owner: <owner>
last_reviewed: 2026-07-24
library: SAIF.Business.External.Users
reference_type: package
---

# SQL-041: Load auditor by AD user and vendor; fallback by vendor

Used by `mdlAuditor.LoadAuditor` to resolve the premium auditor for a given AD user and vendor. First attempts a match by both AD user ID and vendor number; if no result is found, falls back to matching by vendor number alone.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-041 |
| **Operation type** | Read |
| **Execution method** | Inline SQL |
| **Database** | Oracle |
| **Schema** | [unqualified]** |
| **Command type** | Text |
| **Business object** | `mdlAuditor` |
| **Criteria property** | Local SQL |
| **Lifecycle method** | `LoadAuditor` |

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:UserID` | Input | String | 30 | AD user ID (primary query). |
| `:VendorNum` | Input | String | 9 | Vendor number (both queries). |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [PA_AUDITOR](../database-tables.md#pa_auditor) | SELECT | `PA_AUDITOR_ID`, `USER_ID`, `VENDOR_NUM` |

## Sample SQL

```sql
-- Primary: match by user ID and vendor number
SELECT pa_auditor_id FROM pa_auditor
WHERE user_id = :UserID AND vendor_num = :VendorNum;

-- Fallback: match by vendor number only
SELECT pa_auditor_id FROM pa_auditor
WHERE vendor_num = :VendorNum
```

## Operations and processes
- [Premium auditor lookup](../operations/premium-auditor-lookup.md)

> **Note:** Statements marked with `*` were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with `**` could not be confirmed; treat as unknown until verified.

## Sources
- `Business\SAIF.Business.External.Users\mdlAuditor.vb`
