# `PRO_ERPMERGEDELHISTORY` (procedure) - **Type:** PROCEDURE - **Deterministic:** NO - **SQL data access:** CONTAINS SQL ## Parameters | # | Mode | Name | Type | |---|---|---|---| | 1 | IN | `tCreateTime` | `datetime` | | 2 | OUT | `sErrorMsg` | `varchar(100)` | ## Body _Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `PRO_ERPMERGEDELHISTORY`'`._ ## Narrative **Business context:** Platform — denorm-merge reporting retention. Prunes the three big `ERPMERGE*` reporting tables — daily, on a schedule — so historical denormalized rows don't grow unbounded. Companion to the `PRO_ERPMERGEBASE*` push-on-rename family: the base routines keep current rows in sync, this one drops rows that are too old to care about. **What it does:** `DELETE FROM ERPMERGESALSALESORDER`, `ERPMERGEWORKORDER`, `ERPMERGEPRODUCTIONREPORT` where each row's `tCreateDate < tCreateTime`. Cutoff is the caller-supplied threshold. **Invocation:** Called by `ProDao.proErpMergeDelHistory(map)` via MyBatis CALLABLE mapper `ProMapper.xml`. Driven from `MegerDataFactoryServiceImpl.delMergeTableHistoryData()`, which is run by `MergeTableDelHistoryThread` on the Spring `@Scheduled(cron = "0 10 3 * * ?")` daily 03:10 cron (`ScheduledCorn`). No transaction wrapping — three independent `DELETE`s; partial completion is possible if any one fails.