# `Sp_System_DelMsgCheckFlow` (procedure)

> 业务单据保存校验


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

## Parameters

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

## Body

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

## Narrative

**Business context:** 单据删除连带清审批消息 — when a business bill is invalidated or deleted, this proc tears down its parked approval-flow records: the `sysMsg` rows (pending-approval inbox), their `sysmsguser` recipient mappings, and the `sysbillcheckresult` per-condition results. Keeps the in-flight 审批 queue clean when a 单据 is retracted.

**What it does:** Counts `sysMsg WHERE sBillId=sGuid` for the tenant; if zero, returns `sCode=1` (nothing to clean). Otherwise issues three cascading deletes scoped to the bill: `DELETE FROM sysbillcheckresult WHERE sMsgId IN (SELECT sId FROM sysMsg WHERE sBillId=sGuid ...)`, the same for `sysmsguser` keyed on `sParentId`, and finally `DELETE FROM sysMsg WHERE sBillId=sGuid` itself.

**Invocation:** Statically called from `Sp_Calc_sQtt_hm` (报价单 audit slot) inside its uncheck/delete branch, and likely intended for the wider `Sp_Calc_s*` family — only this one current caller in the DB. Install script `script/标版/30100101/Sp_System_DelMsgCheckFlow.sql`. Not bound through any `gdsmodule` / form-master hook; pure proc-to-proc helper.
