# `Fn_find_pinyin` (function)

> 根据拼音查询


- **Type:** FUNCTION
- **Returns:** `varchar(255)`
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `P_NAME` | `varchar(255)` |

## Body

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

## Narrative

**Business context:** Pinyin-initials helper for auto-generated codes. The `Sp_Sis_GetMaxNo` family (which builds the next sequential business code for orders, materials, products, etc.) calls this when a code template embeds a pinyin abbreviation of a name field — e.g., turning customer `北京华佳` into `BJHJ` so it can be used as a code prefix.

**What it does:** walks each character of `P_NAME` (after normalizing full-width parens to ASCII) and concatenates `Fn_fristPinyin(char)` for each. Falls back to the original `P_NAME` if every char yielded empty. Pure string transformation; no table reads.

**Invocation:** called by `Sp_Sis_GetMaxNo`, `Sp_Sis_GetMaxNo_1`, `Sp_Sis_GetMaxNo_New`, and `Sp_Sis_GetMaxNo_copy1` — the next-code generator invoked by save flows across most master forms.
