Page 1 of 1

SQLite function creation routines

Posted: Wed 15 Apr 2015 08:42
by sandy771
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

Re: SQLite function creation routines

Posted: Wed 15 Apr 2015 09:41
by AlexP
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;

Re: SQLite function creation routines

Posted: Wed 15 Apr 2015 09:46
by sandy771
Thanks for the quick reply

Re: SQLite function creation routines

Posted: Wed 15 Apr 2015 09:52
by AlexP
You are welcome. Feel free to contact us if you have any further questions.