VAR
Creates or replaces a temporary, session-only variable, looked up case-insensitively by RUN for a matching :name path or query placeholder; this is step 1 of the resolution precedence, ahead of the current API environment variable, this endpoint's persisted CONFIG API value, and its default (section 7.3, extended by SPRINT XT02B section 4.3). A value may reference ${ENV:NAME} (an operating-system environment variable), resolved once at assignment time; an undefined environment variable fails explicitly. A value containing spaces must be double-quoted. With the trailing PERSIST keyword (requires an active CONNECT API session): instead of a session variable, upserts the value into the current environment's variable set (the same store CONFIG API's Environment tab edits) by case-insensitive name, preserving every other field of an existing row, then clears any session VAR of the same name so the newly persisted environment value is what every subsequent command sees, immediately, through the normal resolution chain.
Arguments
<name>=<value-expression> (mandatory, value-expression may reference ${ENV:NAME}, double-quote a value containing spaces); PERSIST (optional, requires an active CONNECT API session)
Examples
VAR ID=123; VAR COUNTRY=FR; VAR NAME="John Doe"; VAR ID=${ENV:CUSTOMER_ID}; VAR ID=123 PERSIST;
Notes
VAR <name>=<value-expression> [PERSIST];: SPRINT XT02A (URL-Native API Execution), section 2.5/3.2, creates or replaces a session-scoped BroadSQL variable, looked up case-insensitively by RUN for a :name path/query placeholder (section 7.3). Deliberately generic, not tied to any one endpoint (section 8).
A value may reference ${ENV:NAME} (an operating-system environment variable), resolved once, at assignment time (section 16, "assignment-time resolution"); the resulting session variable holds the already-resolved value, not the placeholder text.
Quoting: a value containing spaces must be double-quoted (BroadSQL's existing argument-quoting convention, getArgumentsFromQuery), e.g. VAR NAME="John Doe";. The spec's own example used single quotes; this is a deliberate, documented adaptation to the convention already used everywhere else in BroadSQL (docs/TECHNICAL_CHANGE.md), not a new one invented for this command.
PERSIST (SPRINT XT02B, section 5) is a new implementation, not a restore: XT02A's spec explicitly rejected a flat, endpoint-ambiguous VAR ... PERSIST (section 9.3 there), because a bare name could belong to many endpoints. This version targets a different, unambiguous store: the current API's current environment's variable set (the exact same ApiAttribute rows CONFIG API's Environment tab already edits), which resolves that objection rather than contradicting it. Requires an active CONNECT API session. Upserts the value into that store (by case-insensitive name, preserving every other field of an existing row), then clears any session VAR of the same name (also case-insensitive), so the persisted environment value becomes the single source of truth for that name going forward, immediately visible through the normal resolution chain (session VAR, then API environment variable, then endpoint-specific persisted parameter, then endpoint default) without a stale session override ever masking a later edit again. Plain `VAR name=value; (no PERSIST`) is unchanged: session-only, never touches the database.
Last modified in release 5.2.6.
BroadSQL