type TSLFunction = class(
TSLCustomFun
)
Duering query execution SQLite calls callback to determine result of function or aggregation. From the manager callback can get pointer to function's object and call DoFunction
protected method. Here number of params is checked - in case of problems an error is reported. The Method converts array of PChar to TStringList so the engine is separated from your code but one convertion more is done. At the end event OnFunction
is called.
Parameters are passed as TStrings. Do not change list object - it is common for all calls. You can change values, but I have no idea why.
TSLCustomFun
Name | Description | |
---|---|---|
FParamCount |
||
FParams |
constructor Create (AOwner: TComponent); override; |
|
destructor Destroy; override; |
|
procedure DoFunction (const aParamCount: Integer; const aParams: PPCharArray); virtual; |
|
function GetCallBackPtr: Pointer; virtual; |
|
function GetResTypeAsInt: Integer; |
|
procedure SetActive (const aValue: Boolean); override; |
|
procedure SetParamCount (const aValue: Integer); |
constructor Create (AOwner: TComponent); override; |
destructor Destroy; override; |
procedure DoFunction (const aParamCount: Integer; const aParams: PPCharArray); virtual; |
function GetCallBackPtr: Pointer; virtual; |
function GetResTypeAsInt: Integer; |
procedure SetActive (const aValue: Boolean); override; |
Main process of encounting function result
First number of params is checked - in case of problems an error is reported. The Method converts array of PChar to TStringList so the engine is separated from your code but one convertion more is done. At the end event OnFunction
is called.
procedure SetParamCount (const aValue: Integer); |
Writter of property ParamCount. It allocates space for param list.
property OnFunction: TOnFunction; |
|
property ParamCount: Integer; |
property OnFunction: TOnFunction; |
abstract(Event for function encounting) You can be sure that number of params is propper. Results should be returned with one of methods TSLDatabase.SetResultString
, TSLDatabase.SetResultInt
, TSLDatabase.SetResultDouble
- depends on the result's type. In case of problems TSLDatabase.SetResultError
method should be called
property ParamCount: Integer; |
abstract(Number of parameters used by function)