# `sp_init_gdsjurisdiction` (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_init_gdsjurisdiction`'`._

## Narrative

**Business context:** 系统初始化 / 初始化权限 — one-shot rebuild of `gdsjurisdiction`, the row-level permission catalogue that drives every `Btn*` button-visibility/permission check across the ERP. Operates only on the standard-version tenant (`sBrandsId='1111111111'`, `sSubsidiaryId='1111111111'`); used during install/upgrade to refresh the permission tree from the current form definitions.

**What it does:** Builds temp table `p_TmpTable` of the first form-master per parent (`row_number()=1` over `gdsconfigformmaster GROUP BY sParentId ORDER BY iOrder`). `TRUNCATE TABLE gdsjurisdiction`, then `INSERT INTO gdsjurisdiction` one row per `gdsconfigformslave` whose `sControlName` starts with `Btn`, is visible, and isn't in the ignore-list (`tabSubjectContent`, `tabExamine`) — joining back to the temp parents to scope.

**Invocation:** Status: appears orphaned. No `gdsmodule`, form-master, workflow, or other-routine reference. xly-src ships `script/标版/权限导出/sp_init_gdsjurisdiction.sql` (install script) — no runtime caller. Run manually by DBA during standard-version provisioning.
