# `Sp_Check_sPiv` (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_sPiv`'`._ ## Narrative **Business context:** 采购管理 → 物料采购流程 → 采购发票 — post-save validator on `purpurchaseinvoicemaster`. After the user clicks save, this hook fires before the result is returned, but its real work is to delegate to the after-save calculator: it is a thin pass-through wrapper around `Sp_afterSave_sPiv`. **What it does:** Initialises `sCode=1`, defaults `iFlag` to 0, clears `sReturn`, opens a `top:` block, and immediately calls `Sp_afterSave_sPiv(sGuid, sBrId, sSuId, sCode, sReturn)`. No table touch or validation logic of its own — the entire enforcement lives in the peer after-save proc. **Invocation:** Bound to `gdsmodule.sSaveProName` on `采购发票` (`19211681019715782883617940`). Dispatched by `BusinessBaseServiceImpl.checkUpdate(..., "sSaveProName")` after the save batch commits. Pre-save peer is `Sp_beforeSave_sPiv` (bound on `sSaveProNameBefore`). xly-src has no install script for this exact stub — only the peers ship under `script/标版/30100101/`.