# `Sp_Check_eleteststandardProduct` (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_eleteststandardProduct`'`._

## Narrative

**Business context:** 成品检验规则单据 → 质检规则设定 → 质量管理 — before saving a finished-goods inspection rule, prevent the same product from being registered in more than one active rule so the FQC engine picks an unambiguous standard.

**What it does:** Cursors `eleteststandardobject` rows under `sGuid` (the rule being saved), and for each `sTestObjectId` (product), counts other `eleteststandard` rows in form `12012615914116374917672960` (成品检验规则单据) carrying the same object. If any exist, sets `sReturn` to the localised `sStandardHaveProduct` message plus the conflicting rule names and returns `sCode = -1`. Also rejects duplicate products 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`.
