Declaration¶
Source position: db.pas line 1525
type
TParams = class(TCollection)
public
constructor Create(AOwner: TPersistent;
AItemClass: TCollectionItemClass); overload;
constructor Create(AOwner: TPersistent); overload;
constructor Create; overload;
procedure AddParam;
procedure AssignValues;
function CreateParam : TParam;
function FindParam : TParam;
procedure GetParamList;
function IsEqual : Boolean;
function GetEnumerator : TParamsEnumerator;
function ParamByName : TParam;
function ParseSQL(const SQL: string; DoCreate: Boolean) : string; overload;
function ParseSQL(const SQL: string; DoCreate: Boolean;
EscapeSlash: Boolean; EscapeRepeat: Boolean;
ParameterStyle: TParamStyle) : string; overload;
function ParseSQL(const SQL: string; DoCreate: Boolean;
EscapeSlash: Boolean; EscapeRepeat: Boolean;
ParameterStyle: TParamStyle;
out ParamBinding: TParamBinding) : string; overload;
function ParseSQL(const SQL: string; DoCreate: Boolean;
EscapeSlash: Boolean; EscapeRepeat: Boolean;
ParameterStyle: TParamStyle;
out ParamBinding: TParamBinding;
out ReplaceString: string) : string; overload;
function ParseSQL(const SQL: string; Options: TSQLParseOptions;
ParameterStyle: TParamStyle;
out ParamBinding: TParamBinding; MacroChar: char;
out ReplaceString: string) : string;
procedure RemoveParam;
procedure CopyParamValuesFromDataset;
property Dataset: TDataSet; {r}
property Items[Index : Integer]: TParam; {rw}
property ParamValues[const ParamName : string]: Variant; {rw}
end;
Inheritance¶
Description¶
TParams is a collection of TParam values. It is used to specify parameter values for parameterized SQL statements, but is also used to specify parameter values for stored procedures. Its default property is an array of TParam values. The class also offers a method to scan a SQL statement for parameter names and replace them with placeholders understood by the SQL engine: TParams.ParseSQL.
TDataset itself does not use TParams. The class is provided in the DB unit, so all TDataset descendents that need some kind of parameterization make use of the same interface. The TMasterParamsDataLink class can be used to establish a master-detail relationship between a parameter-aware TDataset instance and another dataset; it will automatically refresh parameter values when the fields in the master dataset change. To this end, the TParams.CopyParamValuesFromDataset method exists.
Properties¶
| Member | Visibility | Description |
|---|---|---|
| Dataset read only | public | Dataset that owns the TParams instance. |
| Items | public | Indexed access to TParams instances in the collection. |
| ParamValues | public | Named access to the parameter values. |
Methods¶
| Member | Visibility | Description |
|---|---|---|
| AddParam | public | Add a parameter to the collection. |
| AssignValues | public | Copy values from another collection. |
| CopyParamValuesFromDataset | public | Copy parameter values from the fields in a dataset. |
| Create | public | Create a new instance of TParams. |
| CreateParam | public | Create and add a new parameter to the collection. |
| FindParam | public | Find a parameter with given name. |
| GetEnumerator | public | Return an enumerator for the parameters. |
| GetParamList | public | Fetch a list of TParam instances. |
| IsEqual | public | Is the list of parameters equal. |
| ParamByName | public | Return a parameter by name. |
| ParseSQL | public | Parse SQL statement, replacing parameter names with SQL parameter placeholders. |
| RemoveParam | public | Remove a parameter from the collection. |
See also¶
| Name | Description |
|---|---|
| TDataset | Base class for records-based data-access. |
| TMasterParamsDataLink | Class to establish a master-detail relationship between dataset, based on parameters. |
| TParam | Parameter description class. |
| TParams.ParseSQL | Parse SQL statement, replacing parameter names with SQL parameter placeholders. |
| TParams.CopyParamValuesFromDataset | Copy parameter values from the fields in a dataset. |