[yunqa.de] Re: Adding user defined functions to sqlite sql?

  • From: Delphi Inspiration <delphi@xxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Sat, 19 Sep 2015 22:04:29 +0200

On 19.09.2015 18:19, H M wrote:

I have a need to calulate the mode and median of some data grouped
over a main grouping with 5 clasifications, each of which has 5
subgroups groups. It occurred to me that this might be easier if I
wrote a Delphi function to do it and called that function in the
sql.

Is it possible to extend the sql used by disqlite3 to call Delphi
functions?

Yes. Interfaces you need are

function sqlite3_create_function(
DB: sqlite3_ptr;
const zFunctionName: PUtf8Char;
nArg: Integer;
eTextRep: Integer;
pApp: Pointer;
xFunc: TSQLite3_Func_Callback;
xStep: TSQLite3_Step_Callback;
xFinal: TSQLite3_Final_Callback): Integer;

or

function sqlite3_create_function_v2(
DB: sqlite3_ptr;
const zFunctionName: PUtf8Char;
nArg: Integer;
eTextRep: Integer;
pApp: Pointer;
xFunc: TSQLite3_Func_Callback;
xStep: TSQLite3_Step_Callback;
xFinal: TSQLite3_Final_Callback;
xDestroy: TSQLite3_Destroy_Callback): Integer;

Look up the details in the DISQLite3.chm documentation.

Look at the DISQLite3Functions.pas source code for example implementations.

Ralf
_______________________________________________
Delphi Inspiration mailing list
yunqa@xxxxxxxxxxxxx
//www.freelists.org/list/yunqa



Other related posts: