# `Sp_beforeSave_sMpt` (procedure)

> 产品工艺卡保存前反写状态


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

## Parameters

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

## Body

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

## Narrative

**Business context:** Product 产品工艺卡 (product technology card) — before-save handler that clears the cached `sProductTechnologyId` on downstream sales-opportunity products and sales-dev-plan masters whose `sSrcSlaveId` resolves through `mftproductslave` to the saved product. Forces consuming records to re-resolve the active technology card after the master save. Comment header: `产品工艺卡保存前反写状态`.

**What it does:** Wraps `sGuid` to a quoted-CSV form, builds a two-statement dynamic SQL string updating `salsaleschanceproduct.sProductTechnologyId=''` and `salsalesdevplanmaster.sProductTechnologyId=''` for rows whose `sId` is linked via `mftproductslave.sSrcSlaveId` to slaves under `sParentId IN (sGuid)`, scoped by `sBrandsId` / `sSubsidiaryId`. Splits the buffer by `;` and runs each via `PREPARE` / `EXECUTE` / `DEALLOCATE`.

**Invocation:** No `gdsmodule` hook in the live DB. Called by dispatcher procs `Sp_Invalid_backwriting` and `Sp_delete_backwriting` to replay the technology-cache reset on invalidate/delete. Install script: `xly-src/script/标版/30100101/Sp_beforeSave_sMpt.sql`.

Flag: master-save coverage relies on dispatchers; the procedure name implies a `sSaveProNameBefore` slot but none is wired up in this DB.
