Record: TParseResult |
Unit: EgStrParser
SQLExpression: string;
The complete comparison fragment, ready to follow a column name in a
WHERE clause. Its operator depends on the TSqlOperator and on the
shape of the input; its literals depend on the TSqlDialect.
| ResultType | SQLExpression (examples) |
|---|---|
otSingleValue |
= 42, <> 'abc',
>= DATE '2026-03-25',
LIKE 'abc%' ESCAPE '\' |
otList |
IN (1, 2, 3), NOT IN ('a', 'b'),
CONTAINS ANY 'w1 w2' |
otRange |
BETWEEN 1 AND 100,
NOT BETWEEN 1 AND 100 |
otEmpty |
IS NULL, IS NOT NULL, = ''
(itString without opEmptyStringNull) |
otInvalid |
Empty. |
All values coming from the user are escaped by the rules of the dialect (see SQL dialects), so the fragment can be concatenated into the SQL text.
R := ParseInput('100~500', itDecimal);
Query1.SQL.Text := 'SELECT * FROM Orders WHERE Amount ' + R.SQLExpression;
// SELECT * FROM Orders WHERE Amount BETWEEN 100 AND 500