Parameters
Placeholders (?, $N, $name) stand in for values supplied alongside the SQL text and are substituted before compilation.
Positional Single
A lone ? resolves to the first list element.
SQL
select ?;
Result
[
42
]
Each ?
Each ? consumes the next list slot in source order.
SQL
select [?, ?, ?];
Result
[
[ 1, 2, 3 ]
]
Positional String
A string parameter.
SQL
select ?;
Result
[
"hello"
]
Positional null
A null parameter.
SQL
select ?;
Result
[
null
]
Parameters Compose
Parameters compose inside an expression.
SQL
select ? + ?;
Result
[
30
]
$1 Is
$1 is the first (1-based) list element.
SQL
select $1;
Result
[
7
]
The Same
The same index may be referenced more than once.
SQL
select [$1, $1, $2];
Result
[
[ 9, 9, 8 ]
]
Numbered References
Numbered references pick by index, not by appearance.
SQL
select [$2, $1];
Result
[
[ "b", "a" ]
]
The First
The first ? and $1 both resolve to list[0].
SQL
select [?, $1];
Result
[
[ 5, 5 ]
]
Named Single
A named parameter resolves from the map.
SQL
select $foo;
Result
[
99
]
Several Named Parameters
Several named parameters.
SQL
select [$a, $b];
Result
[
[ 1, 2 ]
]
Where Positional
A parameter as a where-clause operand.
SQL
create table T;
insert into T ({"x": 1}, {"x": 2}, {"x": 3});
select * from T where T.x > ?;
Result
[
{ "x": 2 },
{ "x": 3 }
]
Where Named
A named parameter in a Where clause.
SQL
create table T;
insert into T ({"x": 1}, {"x": 2});
select * from T where T.x = $val;
Result
[
{ "x": 2 }
]
Keyed Get Positional
A parameter as a keyed-table index (substituted to a literal key).
SQL
create table t (id int);
insert into t ({"id": 1, "v": "a"}, {"id": 2, "v": "b"});
select t[?];
Result
[
{ "id": 2, "v": "b" }
]
? With
? with too few list elements is a bind error.
SQL
select [?, ?];
Expected error: static
$2 With
$2 with a one-element list is a bind error.
SQL
select $2;
Expected error: static
An Absent
An absent named key is a bind error.
SQL
select $foo;
Expected error: static
$0 Is
$0 is out of range (numbering is 1-based).
SQL
select $0;
Expected error: static
Numbered Overflow
A numbered index past u32 is a static bind error, not an opaque lexer error.
SQL
select $4294967296;
Expected error: static
No Parameters Supplied
A placeholder with no parameters at all is a bind error.
SQL
select ?;
Expected error: static