Help with Create own Function in sqlite with Zeos

Forum related to SQLite

Moderators: gto, cipto_kh, EgonHugeist

Fresh Boarder
Fresh Boarder
Posts: 13
Joined: 14.11.2011, 20:21

Help with Create own Function in sqlite with Zeos

Postby Sapiem » 13.01.2013, 02:17


Please, I need create any function like Pos() inside sqlite. There is sqlite_create_function, but I don't know how to use/translate it to use with Zeos in Delphi.

User avatar
Zeos Dev Team
Zeos Dev Team
Posts: 1739
Joined: 31.03.2011, 22:38

Postby EgonHugeist » 14.01.2013, 21:26


Oh that's not so easy to implement in the current Zeos-Design. I had a look how we could implement such interfaces for callback-functions but i must admit currently i've no clue how to support such things from the plain-layer up to the component-layer.

The transaltion of this litte C-Lines isn't the problem. Further more is this a very spezial implementation for one protocol. It might be possible if you switch down to the dbc-layer??..
King regards, Michael

You want to help? viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude!


User avatar
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium

Postby mdaems » 30.01.2013, 21:10

I suppose it would be possible to implement this on the dbc level the way the encryption stuff has been implemented: by adding methods to the TZSQLiteConnection that allow to attach the callback functions.

Another place in the zeoslib codebase where we're doing something with callback functions in the postgresql driver : look for DefaultNoticeProcessor in ZDbcPostgreSql.pas. (There we replace the default notice processor of the postgres library by a callback function of our own to avoid the notices are written to STDOUT in console apps)

So Sapiem, I'm sure this is possible, but you'll have to dive in the code yourself, I'm afraid. If you're used to writing callback functions for sqlite, I'm sure this shouldn't be a problem. And if you have it working fine, just share the code. So we can integrate it in a next zeoslib version.

User avatar
Zeos Dev Team
Zeos Dev Team
Posts: 132
Joined: 26.08.2005, 08:12
Location: Cancún

Help with Create own Function in sqlite with Zeos [Hints]

Postby fduenas » 16.05.2013, 04:04

Hi To all just wanted to give my two cents about this:

You should take a look to the project:


Specially the SQLite 3 components

There Tim Anderson have already translated the headers necessary to register custom functions, what we would need is a wrapper for zeos only that will manage those functions and register them into SQL API

Check specially these sources: ... 3%2FSource

Here are the Headers for the DLL: ... QLite3.pas

Here are the definition and management of custom functions: ... Table3.pas

Here are the definition for managing virtual tables: ... Table3.pas

And check the test cases to see how it works: ... rce%2FTest

They also have added what in Sqlite is named virtual tables.

I have used once an implementation where you can link other Tdatasets with this virtual tables and you can run a full query over them. These virtual tables are only wrappers and cursors for each linked Tdataset so they will work over the TDataset data, but you can achieve a big goal:

Use ZEOS to run queries over any Tdataset compatible componet. Like the old and now renewed TxQuery ( which personally I'm giving support with other developers:


Here is a link of a commercial component, formerly named anyDAC and that now is FireDAC and is part of Embarcadero suite. you can see what can be achieved with Virtual tables, they called it there LocalSQL, but they implement SQLite virtual tables. ... l-sql.html

Regards to all of you.

Return to “SQLite”

Who is online

Users browsing this forum: No registered users and 1 guest