Functions

ParseInput

ParseInput is the core function of the library. It parses a raw text string according to a declared data type and returns a TParseResult record containing the parsed values, SQL literals, and a ready SQL comparison fragment.

Five overloads are provided. Overload 1 is the full form and is thread-safe. Overloads 2–5 are convenience forms that read the global default dialect set by SetSQLDialect.

Overload 1 — full form (thread-safe)

function ParseInput(
  const Input      : string;
        ValueType  : TInputType;
        RangeSep   : Char;
        Options    : TParseOptions;
        SqlOperator: TSqlOperator;
        SqlDialect : TSqlDialect): TParseResult;

All parameters are supplied by the caller. The global default dialect is never read; each call is fully independent and safe to use from any thread.

Overload 2

function ParseInput(
  const Input      : string;
        ValueType  : TInputType;
        Options    : TParseOptions;
        SqlOperator: TSqlOperator): TParseResult;

RangeSep defaults to '~'. Uses GDefaultDialect.

Overload 3

function ParseInput(
  const Input    : string;
        ValueType: TInputType;
        Options  : TParseOptions): TParseResult;

RangeSep defaults to '~', SqlOperator defaults to sopEqual. Uses GDefaultDialect.

Overload 4

function ParseInput(
  const Input      : string;
        ValueType  : TInputType;
        SqlOperator: TSqlOperator): TParseResult;

RangeSep defaults to '~', Options defaults to []. Uses GDefaultDialect.

Overload 5 — minimal form

function ParseInput(
  const Input    : string;
        ValueType: TInputType): TParseResult;

RangeSep defaults to '~', Options defaults to [], SqlOperator defaults to sopEqual. Uses GDefaultDialect.

Parameters

Parameter Type Description
Input string Raw text from the UI control. May contain spaces, quotes, list separators, or the range separator.
ValueType TInputType The data type the input is expected to represent.
RangeSep Char Character that separates the two bounds of a range. Default: '~'. Must not be ',', ';', '-', '.', '''' (single quote), or ' ' (space); any of these causes ERR_INVALID_RANGESEP.
Options TParseOptions Set of TParseOption flags. Default: [].
SqlOperator TSqlOperator Comparison operator for SQLExpression. Default: sopEqual.
SqlDialect TSqlDialect SQL dialect for literal formatting (overload 1 only).

Return value

A TParseResult record. ParseInput never raises an exception in release builds; all error conditions are reported through TParseResult.ErrorCode and TParseResult.ResultType = otInvalid. See Types and constants for the full field reference and Error codes for error handling guidance.

NULL and empty token behavior

An empty token within a list (e.g. 1,,3) produces NULL in SQL for all typed input types (itInteger, itDecimal, itFloat, itBoolean, itDate, itTime, itDateTime), and an empty quoted string '' for itString (unless opEmptyStringNull is set). Example: input 1,,3 with itInteger produces IN (1, NULL, 3).

An empty range bound likewise produces NULL. BETWEEN NULL AND x, BETWEEN x AND NULL, and BETWEEN NULL AND NULL are syntactically valid SQL but will never match any row, as any comparison with NULL yields UNKNOWN. No error is raised; use opNotNull to reject empty tokens if a NULL bound is not acceptable.

Thread safety

Overload 1 is thread-safe; overloads 2–5 read the global GDefaultDialect and are safe only when SetSQLDialect is not called concurrently. See Thread safety for the full analysis and recommended patterns.


SetSQLDialect

procedure SetSQLDialect(Dialect: TSqlDialect);

Sets the global default dialect used by overloads 2–5 of ParseInput. The default value at application startup is sqlElevateDB. See TSqlDialect. Not thread-safe: do not call this procedure while other threads may be calling overloads 2–5.


GetSQLDialect

function GetSQLDialect: TSqlDialect;

Returns the current global default dialect. The return value reflects the last call to SetSQLDialect, or sqlElevateDB if SetSQLDialect has never been called. Not thread-safe for the same reason as SetSQLDialect.

(C) 2026 Easygate, Lda