Hi
Anybody has written custom UDF for Sqlite 3 using fpc?
If so kindly help me with some hints to get started.
regards
Nataraj

Mailing lists / fpc-pascal / 2009-11
9 messages · 3 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Hi
Anybody has written custom UDF for Sqlite 3 using fpc?
If so kindly help me with some hints to get started.
regards
Nataraj
See the attached files. It implements a custom format date function
Luiz
Hi Luiz
Getting this:-
/software/fpc-uclibc/lib/fpc/2.5.1/ppcrossarm -MObjFPC -TLinux -Parmv5 -gl -Xd -Xs -l -darm -XParm-linux-uclibcgnueabi- -CfSOFT -CaEABI -darm -gl -O- -CpARMV5 -uUSE_LOCALIZE
-Fu/software/fpc-arm/units/arm-linux/ testfunction.pas Free Pascal Compiler version 2.5.1 [2009/10/23] for arm Copyright (c) 1993-2009 by Florian Klaempfl
Target OS: Linux for ARM
Compiling testfunction.pas
testfunction.pas(25,66) Error: Identifier not found "sqlite3_value_int" testfunction.pas(42,21) Error: Identifier not found "sqlite3_result_int" testfunction.pas(59,23) Error: Identifier not found "sqlite3_result_int" testfunction.pas(62,25) Error: Identifier not found "sqlite3_result_int" testfunction.pas(65,27) Error: Identifier not found "sqlite3_result_int" testfunction.pas(124) Fatal: There were 5 errors compiling module, stopping Fatal: Compilation aborted
Any Sqlite version problem?
On SQLite version 3.4.2
regards
Nataraj
It's compiling here both with fpc224 and 251 but for win32.
It seems a problem in the sqlite3 header for arm
Luiz
Luiz
Got it compiled for arm after putting libsqlite in proper path. Getting this:-
# ./testfunction
./testfunction: can't resolve symbol 'dl_iterate_phdr'
BTW, this function should be compiled to a lib.so first? Then call it in a trigger ?
regards
Nataraj
I have no clue what's the problem. Maybe someone else can help
BTW, this function should be compiled to a lib.so first? Then call it in a trigger ?
No.
In the example a custom function (strftime) is registered with sqlite3_create_function.
After this you can call in a Select. (See example in the same file).
So the only thing that you need is to call sqlite3_create_function in the start of your program with the correct parameters.
Luiz
It should not be sqlite3?
Sorry. It's not in the start of the program. Is just about the first time the SqliteHandle is allocated. In the recent TSqliteDataset there's the OnGetHandle event that's the best place to put this kind of code. But if you are using older versions than you can call after the first Open or do a dummy ExecSql call to force the SqliteHandle allocation
Luiz
Luiz Got it compiled for arm after putting libsqlite in proper path. Getting this:- #…
hi luiz
I translated the sqlite3 headers, but never tested them on arm. Maybe I can help, but I need more information or some arm emulator with os.
-Ivo Steinmann
I looked at the header and could not find any reason to not work. Seems something specific for arm-linux
@Nataraj: What component are you using to access sqlite? SqlDB or Sqliteds? The later uses the static header while the former the dynamic one
Luiz