# `Sp_PurchasePriceChar` (procedure)


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `tStartDate` | `datetime` |
| 2 | IN | `tEndDate` | `datetime` |
| 3 | IN | `sLoginId` | `varchar(100)` |
| 4 | IN | `sBrId` | `varchar(100)` |
| 5 | IN | `sSuId` | `varchar(100)` |
| 6 | OUT | `sReturn` | `varchar(8000)` |
| 7 | OUT | `sCode` | `int` |

## Body

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

## Narrative

**Business context:** 采购管理 → 采购分析 — chart-side JSON producer for the paper-material price trend (sibling of `Sp_PurchasePrice` which returns a table). Emits an ECharts-style `{"data":[{"type":..., "x":..., "y":...}, ...], "xUnit":"", "yUnit":""}` payload in `sReturn`, one point per (material × purchase date), feeding a line-chart widget on the 采购分析 dashboard.

**What it does:** Same paper-price filter as `Sp_PurchasePrice` — builds temp `T` from `viw_purpurchaseorder` joined to `elematerials`/`sismaterialsclassify` (`bCheck=1 AND sMaterialsType='paper'` in window). Distincts materials into `DT`, then nested cursors walk each material's (`tCreateDate`, `dMaterialsPrice`) tuples, dynamically ALTERing `DT` to add per-date columns *and* concatenating each `{type, x, y}` JSON object into `p_sText`. Wraps `p_sText` with the outer `data/xUnit/yUnit` envelope and returns it as `sReturn`.

**Invocation:** Status: appears orphaned. No caller found in any channel (form-master, gdsmodule hooks, other routines, xly-src grep across all extensions). Likely the `Sp_Bd_*` dashboard variant of `Sp_PurchasePrice` referenced via `gdsconfigcharmaster.sProcedureName` for a chart slot, but no such row exists in the live DB — candidate for maintainer audit. Sibling: the slightly newer `Sp_PurchasePriceChart` which loops over `DT` without populating that temp table first (likely a bug).
