# `Sp_MaterialsStoreVirtual_refresh` (procedure)

> 材料虚拟库存刷新


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

## Parameters

_No parameters._

## Body

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

## Narrative

**Business context:** 仓库管理 → 虚拟库存 — 材料虚拟库存刷新, the batch utility that walks every active 工单 (`mftworkordermaster`) and rebuilds its virtual-stock projection. Used to repair the `mitmaterialsstorevirtual` table after upstream changes (calc errors, mass imports) so that planning views reflect what is really committed.

**What it does:** Opens a cursor over `mftworkordermaster` rows where `bInvalid=0 AND bCheck=1`, then for each row calls `Sp_MaterialsStoreVirtual(sId, sBrandsId, sSubsidiaryId)` — the single-order rebuild proc. No filtering by branch or subsidiary at the cursor level (the sub-call handles tenant scoping).

**Invocation:** Status: appears orphaned. No `gdsmodule`/`gdsconfigformmaster` row references it, no other procedure calls it, and the only xly-src hit is the install script `script/标版/材料库存/Sp_MaterialsStoreVirtual_refresh.sql`. Likely a manual maintenance utility — operators run it from a DB console or as a scheduled job not registered in the wiki's scope. Candidate for maintainer audit.
