On this page

VAR

Core command

Sets an API variable for the session, used by RUN for a :name placeholder, or saves it with PERSIST.

Syntax

VAR <name>=<value> [PERSIST]

Arguments

ArgumentRequiredValuesDefault
<name>=<value>YesA name and a value; the value may use ${ENV:NAME}, and is in double quotes when it has spacesNone
PERSISTNo. Needs a CONNECT API session.Saves the value in the current API environmentSession only

Examples

VAR ID=123;
VAR COUNTRY=FR;
VAR NAME="John Doe";
VAR ID=${ENV:CUSTOMER_ID};
VAR ID=123 PERSIST;

Details

Session variables

VAR <name>=<value> creates or replaces a variable for the session. RUN uses it, matching the name ignoring case, for a :name placeholder of a URL, first in this order: the session variable, the variable of the current API environment, the value saved for the endpoint in CONFIG API, the endpoint's default. A variable is not tied to one endpoint.

  • A value may use ${ENV:NAME}, an operating system environment variable, read once when VAR runs: the variable keeps the value, not the placeholder. An undefined environment variable fails the command.
  • A value containing spaces is written in double quotes: VAR NAME="John Doe";.

PERSIST

With PERSIST, which needs a CONNECT API session, the value is saved in the variables of the current environment of the current API, the same variables the Environment tab of CONFIG API edits. An existing variable of the same name, ignoring case, keeps its other fields. A session variable of the same name is then removed, so the saved value is what every later command sees. Without PERSIST, nothing is saved in the CDF.

API variables only

VAR sets API variables only; they are never visible in SQL. Scripting variables, used in SQL as ${name}, are set with LET and listed with SHOW SCRIPT VARIABLES.

Last modified in release 5.5.0.

Found something wrong or unclear on this page? , with the page address.