Unit 'DB' Package
[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] [#fcl]

TParams.ParseSQL

Parse SQL statement, replacing parameter names with SQL parameter placeholders.

Declaration

Source position: db.pas line 1547

public function TParams.ParseSQL(

  const SQL: string;

  DoCreate: Boolean

):string; overload;

function TParams.ParseSQL(

  const SQL: string;

  DoCreate: Boolean;

  EscapeSlash: Boolean;

  EscapeRepeat: Boolean;

  ParameterStyle: TParamStyle

):string; overload;

function TParams.ParseSQL(

  const SQL: string;

  DoCreate: Boolean;

  EscapeSlash: Boolean;

  EscapeRepeat: Boolean;

  ParameterStyle: TParamStyle;

  out ParamBinding: TParamBinding

):string; overload;

function TParams.ParseSQL(

  const SQL: string;

  DoCreate: Boolean;

  EscapeSlash: Boolean;

  EscapeRepeat: Boolean;

  ParameterStyle: TParamStyle;

  out ParamBinding: TParamBinding;

  out ReplaceString: string

):string; overload;

function TParams.ParseSQL(

  const SQL: string;

  Options: TSQLParseOptions;

  ParameterStyle: TParamStyle;

  out ParamBinding: TParamBinding;

  MacroChar: char;

  out ReplaceString: string

):string;

Arguments

SQL

  

SQL statement to scan for parameter names.

DoCreate

  

Set to True if TParam instances must be created for the found parameters.

Function result

SQL statement with parameter names replaced with placeholders.

Arguments

SQL

  

SQL statement to scan for parameter names.

DoCreate

  

Set to True if TParam instances must be created for the found parameters.

EscapeSlash

  

True if the backslash character acts as an escape token.

EscapeRepeat

  

True if quotes are escaped by specifying them two times.

ParameterStyle

  

SQL Placeholder style.

Arguments

SQL

  

SQL statement to scan for parameter names.

DoCreate

  

Set to True if TParam instances must be created for the found parameters.

EscapeSlash

  

True if the backslash character acts as an escape token.

EscapeRepeat

  

True if quotes are escaped by specifying them two times.

ParameterStyle

  

SQL Placeholder style.

ParamBinding

  

On return, filled with indexes of TParam instances corresponding to the placeholders.

Arguments

SQL

  

SQL statement to scan for parameter names.

DoCreate

  

Set to True if TParam instances must be created for the found parameters.

EscapeSlash

  

True if the backslash character acts as an escape token.

EscapeRepeat

  

True if quotes are escaped by specifying them two times.

ParameterStyle

  

SQL Placeholder style.

ParamBinding

  

On return, filled with indexes of TParam instances corresponding to the placeholders.

ReplaceString

  

Placeholder string.

Arguments

SQL

  

SQL statement to scan for parameter names.

Options

  

Contains the parser options enabled when parsing the SQL statement.

ParameterStyle

  

SQL Placeholder style.

ParamBinding

  

On return, filled with indexes of TParam instances corresponding to the placeholders.

MacroChar

  

Character which triggers expansion of a named macro in the SQL statement.

ReplaceString

  

Placeholder string.

Description

ParseSQl parses the SQL statement for parameter names in the form :ParamName. It replaces them with a SQL parameter placeholder. If DoCreate is True then a TParam instance is added to the collection with the found parameter name.

The parameter placeholder is determined by the ParameterStyle property, which can have the following values:

psInterbase
Parameters are specified by a ? character.
psPostgreSQL
Parameters are specified by a $N character.
psSimulated
Parameters are specified by a $N character.

psInterbase is the default.

If the EscapeSlash parameter is True, then backslash characters are used to quote the next character in the SQL statement. If it is False, the backslash character is regarded as a normal character.

If the EscapeRepeat parameter is True (the default) then embedded quotes in string literals are escaped by repeating themselves. If it is false then they should be quoted with backslashes.

ParamBinding, if specified, is filled with the indexes of the parameter instances in the parameter collection: for each SQL parameter placeholder, the index of the corresponding TParam instance is returned in the array.

ReplaceString, if specified, contains the placeholder used for the parameter names (by default, $). It has effect only when ParameterStyle equals psSimulated.

The function returns the SQL statement with the parameter names replaced by placeholders.

See also

TParam

  

Parameter description class.

TParam.Name

  

Name of the parameter.

TParamStyle

  

Style of parameter.


Documentation generated on: Dec 26 2024