# `Sp_ReplaceField_Calc` (procedure) > 公式语言转换成sql - **Type:** PROCEDURE - **Deterministic:** NO - **SQL data access:** CONTAINS SQL ## Parameters | # | Mode | Name | Type | |---|---|---|---| | 1 | IN | `sGuid` | `varchar(100)` | | 2 | IN | `sSlaveGuid` | `varchar(100)` | | 3 | IN | `sDetail` | `longtext` | | 4 | IN | `sFormulaGuid` | `varchar(100)` | | 5 | OUT | `sReturn` | `longtext` | | 6 | IN | `sLoginId` | `varchar(100)` | | 7 | IN | `sBrId` | `varchar(100)` | | 8 | IN | `sSuId` | `varchar(100)` | | 9 | IN | `sCode` | `int` | ## Body _Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `Sp_ReplaceField_Calc`'`._ ## Narrative **Business context:** Formula-engine support — given a master/slave row and a formula sId from `sisformula`, parses each `set @rN_xxx := value` statement out of `sisformula.sFormulaSet` and persists the named parameter+value into `mftcalcparam` so downstream calculators (报价/工艺成本) can look it up. COMMENT `'公式语言转换成sql'` ("formula language → SQL"). **What it does:** Loads `sFormulaSet` and Chinese name map `sColTitleName` from `sisformula` for the brand/sub. Splits `sFormulaSet` by `;`, and for each `set @rN_ := ` clause: extracts `p_sName` and `p_sValue`, looks up `p_sChineseName` from the JSON column-title map, then either `INSERT INTO mftcalcparam (sSrcId=sGuid, sSrcSlaveId=sSlaveGuid, sParamName, sChineseName, sParamValue)` when the name still appears in `sDetail`, or `DELETE FROM mftcalcparam` for that key when the name is no longer referenced. Surfaces any externally-set `@sReturn` to the OUT. **Invocation:** Called as `CALL Sp_ReplaceField_Calc(...)` from the quotation/work-order parts-standard calculators — `Sp_Quotation__CalcDataPackPartsStd` and `Sp_WorkOrder_CalcDataPackPartsStd_child`. Install scripts ship in `script/标版/30100101/Sp_ReplaceField_Calc_.sql` (with the patch under `script/标版/upgrade/20220321计算获取公式解析/`).