Internal parameters

Variables can be defined using the .set command. Variables are then automatically looked for when executing SQL statements for which a variable is required; they are not typed and are converted to the correct type when needed. Note that variables are shared by all the opened connections.

Use the .set <variablename> <variable value> command to define a variable, and the .set command to list all defined variables. The following example illustrates variables usage:

SalesTest> select * from customers where id = ##theid::int;
ERROR: No internal parameter named 'theid' required by query
SalesTest> .set theid 3
SalesTest> select * from customers where id = ##theid::int;
id | name       | default_served_by | country | city
---+------------+-------------------+---------+-----
 3 | Lew Bonito |                 1 | FR      | TLS 
(1 row)
SalesTest> .set theid 5
SalesTest> select * from customers where id = ##theid::int;
id | name | default_served_by | country | city
---+------+-------------------+---------+-----
(0 rows)
SalesTest> .set
List of defined parameters
Name  | Value
------+------
theid | 5    
(1 row)
SalesTest>