Fun_GetGb.md 1.41 KB

Fun_GetGb (function)

获取字符串中数字

  • Type: FUNCTION
  • Returns: varchar(100)
  • Deterministic: NO
  • SQL data access: CONTAINS SQL

Parameters

# Mode Name Type
1 IN str varchar(100)

Body

Body is not pre-cached. To inspect: mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE FUNCTIONFunGetGb'._

Narrative

Business context: Prefix extractor — pulls the non-digit prefix of a bill-number-style string (the "header"/国标 letters before the running counter). Header comment 获取字符串中数字 is misleading; the body keeps non-digit characters, not digits. Paired with Fun_GetNum (digits-only) it lets routines split SO-2024-0001 style codes into prefix SO- and number 20240001.

What it does: walks the input one character at a time. For each char, tests REGEXP '[0-9]'; if it does not match (i.e. non-digit), appends to the result. Returns the assembled non-digit prefix.

Invocation: called from Fun_GetAddBillNo (bill-number incrementer) and from the auto-scheduling family Sp_OneDatePlan_Machine (single-day machine-plan generator on form 1921168137117916508762815480 机台计划达成日报), and Sp_productionPlan_BtnEventAutoOrder3/4/5/6 (production-plan auto-order button events). Also referenced by Sp_Create_sControlFaceNameTable, _TableFive/Four/One/Three/Two (process-name builders).