|
AnyDAC
|
The class implementing custom SQLite function.
uADPhysSQLite
Use the TADSQLiteFunction to register a custom SQLite function. A registered function then may be used in any place in SQL command, where an expression may be used.
TADSQLiteFunction = class(TADSQLiteService);
ADSQLiteFunction1.DriverLink := ADPhysSQLiteDriverLink1; ADSQLiteFunction1.FunctionName := 'MyFunc'; ADSQLiteFunction1.ArgumentsCount := 2; ADSQLiteFunction1.Active := True; ADSQLiteFunction1.OnCalculate := ADSQLiteFunction1Calculate; procedure TForm1.ADSQLiteFunction1Calculate(AFunc: TSQLiteFunction; AInputs: TSQLiteInputs; AOutput: TSQLiteOutput; var AUserData: TObject); begin AOutput.AsInteger := AInputs[0].AsInteger * AInputs[1].AsInteger; end; procedure TForm1.Button1Click(Sender: TObject); begin // demo query ADQuery1.Open('select RegionID, 'MyFunc'(RegionID, 10) from "Region"'); end;
See <AnyDAC>\Samples\DBMS Specific\SQLite\UserFunction
|
What do you think about this topic? Send feedback!
|