# `PRO_ERPMERGEBASEELEMACHINE` (procedure)


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

## Parameters

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

## Body

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

## Narrative

**Business context:** 基础资料 / 设备 (Machine base data) — when a machine (`ELEMACHINE`) is renamed or renumbered in the **设备** maintenance page, this proc pushes the new `sMachineName`/`sMachineNo` to every historical production-report row that already references that machine.

**What it does:** `SELECT sMachineName, sMachineNo INTO @sMachineName, @sMachineNo FROM ELEMACHINE WHERE sId = sEleMachineId`, then `UPDATE ERPMERGEPRODUCTIONREPORT SET sMachineName = @sMachineName, sMachineNo = @sMachineNo WHERE sMachineId = sEleMachineId`. One-shot denormalization push.

**Invocation:** Reached via `ProDao.proErpMergeBaseEleMachine(map)` → MyBatis `ProMapper.proErpMergeBaseEleMachine` (`CALL PRO_ERPMERGEBASEELEMACHINE(#{sEleMachineId})`). Fired by the entity-change service for `elemachine` (JMS `CHANGE_GDS_MODULE` consumer) 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).
