When ParseInput cannot produce a valid result, it sets
ResultType to otInvalid and returns a non-zero
value in ErrorCode. All error conditions are reported this
way; ParseInput never raises an exception in release
builds.
| Constant | Value | Condition |
|---|---|---|
ERR_NONE |
0 |
Success. No error. |
ERR_INVALID_FORMAT |
1 |
A token could not be converted to the declared
TInputType. |
ERR_INVALID_RANGE |
2 |
The left range bound is greater than the right bound. |
ERR_LIST_SEPARATOR_CONFLICT |
3 |
Both a list separator (, or ;) and the
range separator were found in the same input. |
ERR_NULL_NOT_ALLOWED |
4 |
opNotNull was set and at least one token resolved to
NULL. |
ERR_EMPTY_NOT_ALLOWED |
5 |
opRequired was set and the whole input was empty. |
ERR_INVALID_RANGESEP |
6 |
The RangeSep character is one of the reserved
characters: ,, ;, -,
., ' (single quote), or space. |
The input contains a token that cannot be parsed as the declared type.
Common causes:
itInteger: non-numeric characters, decimal point,
exponent (3.14, 3e4).itDecimal / itFloat: token contains both
. and , (1,234.5).itBoolean: word is not one of the accepted
aliases.itDate: string cannot be parsed as a date by any of the
recognised formats.itTime: format is not hh:mm,
hh:mm:ss, or hh:mm:ss.f[ff[fff]]; trailing
dot; more than 6 fractional digits; AM/PM combined with fractional
seconds.itDateTime: date part or time part fails to parse.itFloat: absolute value exceeds the Double
maximum (~1.8E308).R := ParseInput('3.14', itInteger);
// R.ResultType = otInvalid
// R.ErrorCode = ERR_INVALID_FORMATApplies to itInteger, itDecimal,
itFloat, itDate, itTime, and
itDateTime when the input is a range and the left bound is
strictly greater than the right bound.
itString and itBoolean ranges are never
order-checked.
R := ParseInput('100~1', itInteger);
// R.ResultType = otInvalid
// R.ErrorCode = ERR_INVALID_RANGE
R := ParseInput('2026-12-31~2026-01-01', itDate);
// R.ResultType = otInvalid
// R.ErrorCode = ERR_INVALID_RANGEEqual bounds are allowed: 10~10 produces
BETWEEN 10 AND 10.
The input contains both a list separator (, or
;) and the range separator outside quoted regions. The
parser cannot determine whether the input is a list or a range.
R := ParseInput('1,2~3', itInteger);
// R.ResultType = otInvalid
// R.ErrorCode = ERR_LIST_SEPARATOR_CONFLICTThis error can be avoided by using a range separator that does not appear in the input, or by quoting values that contain the conflicting characters.
opNotNull was set and at least one token in the output
resolved to NULL. This happens when a list position is
empty (1,,3), a range bound is empty (~100),
or the whole input is empty for a non-string type.
For itString, empty tokens produce '' (not
NULL) unless opEmptyStringNull is also
set.
R := ParseInput('1,,3', itInteger, [opNotNull]);
// R.ResultType = otInvalid
// R.ErrorCode = ERR_NULL_NOT_ALLOWEDERR_NULL_NOT_ALLOWED is not set when
ERR_EMPTY_NOT_ALLOWED has already been returned for the
same call.
opRequired was set and the whole input (after
opTrim when present) is empty or whitespace only.
R := ParseInput('', itDate, [opRequired]);
// R.ResultType = otInvalid
// R.ErrorCode = ERR_EMPTY_NOT_ALLOWED
R := ParseInput(' ', itDate, [opRequired, opTrim]);
// R.ResultType = otInvalid
// R.ErrorCode = ERR_EMPTY_NOT_ALLOWEDThe RangeSep character passed to ParseInput
overload 1 is one of the reserved characters: ,,
;, -, ., ' (single
quote), or space. These characters are reserved because they are used by
other parts of the parser:
, and ; are list separators.- appears in ISO date strings
(2026-03-25).. appears in decimal numbers and fractional
seconds.' is used to delimit quoted strings; consuming it as a
range separator would silently discard ranges inside quoted values.itDateTime.When this error occurs, SQLExpression is empty and
Values and SQLValues are nil.
R := ParseInput('a,b', itString, ',', [], sopEqual, sqlElevateDB);
// R.ResultType = otInvalid
// R.ErrorCode = ERR_INVALID_RANGESEPThe recommended pattern is to check ResultType first,
then branch on ErrorCode for user-facing messages:
R := ParseInput(Edit1.Text, itDate, [opRequired]);
case R.ResultType of
otEmpty:
; // no input; no WHERE clause needed
otInvalid:
case R.ErrorCode of
ERR_EMPTY_NOT_ALLOWED:
ShowMessage('Please enter a date.');
ERR_INVALID_FORMAT:
ShowMessage('The date format was not recognised.');
ERR_INVALID_RANGE:
ShowMessage('The start date must not be later than the end date.');
else
ShowMessage('Invalid input (error ' + IntToStr(R.ErrorCode) + ').');
end;
else
Query1.SQL.Text := 'SELECT * FROM Orders WHERE OrderDate ' + R.SQLExpression;
Query1.Open;
end;ParseInput never raises an exception for invalid input
in release builds. The EDemoRestriction exception is raised
only by demo builds when the input exceeds the demo length limit or when
the Delphi IDE is not running.