SQLite function creation routines

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
sandy771
Posts: 194
Joined: Tue 22 May 2007 13:57

SQLite function creation routines

Post by sandy771 » Wed 15 Apr 2015 08:42

is it possible to access the SQLite function creation routines through UniDac to extend the features available whe writing queries

http://www.sqlite.org/c3ref/create_function.html

Thanks

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: SQLite function creation routines

Post by AlexP » Wed 15 Apr 2015 09:41

Hello,

To implement user functions, you can use the TLiteUtils.RegisterFunction method. For example:

Code: Select all

function test(InValues: array of Variant): Variant;
begin
  Result := 'new text';
  //required behavior implementation
end;


procedure TForm14.FormCreate(Sender: TObject);
begin
TLiteUtils.RegisterFunction(UniConnection1, 'TEST', 1, test);
UniQuery1.SQL.Text := 'select TEXT(''old text'') as F_TEXT';
UniQuery1.DataTypeMap.AddFieldNameRule('F_TEXT', ftString);
UniQuery1.Open;
end;

sandy771
Posts: 194
Joined: Tue 22 May 2007 13:57

Re: SQLite function creation routines

Post by sandy771 » Wed 15 Apr 2015 09:46

Thanks for the quick reply

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: SQLite function creation routines

Post by AlexP » Wed 15 Apr 2015 09:52

You are welcome. Feel free to contact us if you have any further questions.

Post Reply