# `PRO_ERPMERGEBASEELEMATERIALS` (procedure)


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sEleMaterialsId` | `varchar(100)` |

## Body

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

## Narrative

**Business context:** 基础资料 / 物料 (Materials base data) — when a material (`ELEMATERIALS`) is renamed or its gram weight is corrected in the **物料** maintenance page, this proc pushes the new `sMaterialsName`/`dGramWeight` to every historical production-report row that already references that material.

**What it does:** `SELECT sMaterialsName, dGramWeight INTO @sMaterialsName, @dGramWeight FROM ELEMATERIALS WHERE sId = sEleMaterialsId`, then `UPDATE ERPMERGEPRODUCTIONREPORT SET sMaterialsName = @sMaterialsName, dGramWeight = @dGramWeight WHERE sMaterialsId = sEleMaterialsId`. One-shot denormalization push.

**Invocation:** Reached via `ProDao.proErpMergeBaseEleMaterials(map)` → MyBatis `ProMapper.proErpMergeBaseEleMaterials` (`CALL PRO_ERPMERGEBASEELEMATERIALS(#{sEleMaterialsId})`). Fired by `ChangeEleMaterialsServiceImpl` (the JMS `CHANGE_GDS_MODULE` consumer for the materials entity) after a base-data row mutates, keeping denormalized reporting tables in sync without a full rebuild. See [Cache invalidation on metadata change](../../reference/maintainer/cache-invalidation.md).
