# `Sp_Check_eleteststandardFirst` (procedure)

> 生产首检规则保存之前数据校验


- **Type:** PROCEDURE
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sTableName` | `varchar(100)` |
| 2 | IN | `sGuid` | `varchar(100)` |
| 3 | IN | `sFormGuid` | `varchar(100)` |
| 4 | IN | `sLoginId` | `varchar(100)` |
| 5 | IN | `sBrId` | `varchar(100)` |
| 6 | IN | `sSuId` | `varchar(100)` |
| 7 | IN | `iFlag` | `int` |
| 8 | OUT | `sCode` | `int` |
| 9 | OUT | `sReturn` | `varchar(4000)` |

## Body

_Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `Sp_Check_eleteststandardFirst`'`._

## Narrative

**Business context:** 生产首检规则单据 → 质检规则设定 → 质量管理 — before saving a production first-piece (首检) inspection rule, prevent the same process from being registered in more than one active rule so the first-piece engine picks an unambiguous standard.

**What it does:** Cursors `eleteststandardobject` rows under `sGuid` (the rule being saved), and for each `sTestObjectId` (process), counts other `eleteststandard` rows in form `12012615914116370215408310` (生产首检规则单据) carrying the same object. If any exist, sets `sReturn` to the localised `sStandardHaveProcess` message plus the conflicting rule names and returns `sCode = -1`. Also rejects duplicate processes within `sGuid` itself.

**Invocation:** Save-time check on form 生产首检规则单据 — invoked via the `Sp_Check_*` dispatcher from the `Sp_Calc_*` save procedure for that form's `sCode`.
