# `Sp_System_CheckSave` (procedure)

> 业务单据保存校验


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

## Parameters

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

## Body

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

## Narrative

**Business context:** Universal 业务单据保存校验 hook — the single fall-through post-save validator that runs for every business form after the per-form `sSaveProName` validator. The procedure is **hard-coded** into Java save handling (not pulled from `gdsmodule`), making it the system-wide place to add tenant-agnostic post-save side-effects. The active body (the approval-routing logic is fully commented out) now does only one thing: copies a configured `SysBillNoSettings.sSrcFormId` onto the just-saved row.

**What it does:** Looks up `SysBillNoSettings.sSrcFormId WHERE sFormId=sFormGuid` for the tenant; if found and `sTableName` is non-empty, builds and EXECUTEs a prepared `UPDATE <sTableName> SET sFormId='<sSrcFormId>' WHERE sId='<sGuid>'`. Everything else in the body — the elecheckmodel scan and the per-slave `Sp_System_CheckSaveFlow` cursor against `saldelivergoodsmaster` — is commented out (`-- 以下代码是一直注释状态，没有启用`). Always returns `sCode=1`.

**Invocation:** Called as the **second pass** of every save by `BusinessBaseServiceImpl.checkUpdateFlow()` via `checkSaveService.getCheckSaveUpdFlow(..., "Sp_System_CheckSave")` (string literal in the Java source) — this runs after the per-module `checkUpdate(..., "sSaveProName")` succeeds. Install script `script/标版/30100101/Sp_System_CheckSave.sql`; an upgrade copy lives at `script/标版/upgrade/20211104单独升级后台包需要执行/Sp_System_CheckSave.sql`.
