Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-11

fpc and Sqlite UDF

9 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Nataraj S Narayan

Hi

Anybody has written custom UDF for Sqlite 3 using fpc?

If so kindly help me with some hints to get started.

regards

Nataraj

Reply by email

Luiz Americo Pereira Camara
to Nataraj S Narayan
Nataraj S Narayan wrote 6 lines
Hi Anybody has written custom UDF for Sqlite 3 using fpc? If so kindly help me with some hints to get started.

See the attached files. It implements a custom format date function

Luiz

Reply by email

Nataraj S Narayan
to Luiz Americo Pereira Camara

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

Luiz Americo Pereira Camara wrote 17 lines
Nataraj S Narayan escreveu: > > Hi > > Anybody has written custom UDF for Sqlite 3 using fpc? > > If so kindly help me with some hints to get started. > See the attached files. It implements a custom format date function Luiz _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Luiz Americo Pereira Camara
to Nataraj S Narayan
Nataraj S Narayan wrote 26 lines
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

It's compiling here both with fpc224 and 251 but for win32.

It seems a problem in the sqlite3 header for arm

Luiz

Reply by email

Nataraj S Narayan
to Luiz Americo Pereira Camara

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

Luiz Americo Pereira Camara wrote 39 lines
Nataraj S Narayan escreveu: > > 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 > > It's compiling here both with fpc224 and 251 but for win32. It seems a problem in the sqlite3 header for arm Luiz _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Luiz Americo Pereira Camara
to Nataraj S Narayan
Nataraj S Narayan wrote 8 lines
Luiz Got it compiled for arm after putting libsqlite in proper path. Getting this:- # ./testfunction ./testfunction: can't resolve symbol 'dl_iterate_phdr'

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

Reply by email

Luiz Americo Pereira Camara
to Luiz Americo Pereira Camara
Luiz Americo Pereira Camara wrote 12 lines
Nataraj S Narayan escreveu: > Luiz > > Got it compiled for arm after putting libsqlite in proper path. > Getting this:- > > # ./testfunction > > ./testfunction: can't resolve symbol 'dl_iterate_phdr' > I have no clue what's the problem. Maybe someone else can help

It should not be sqlite3?

Show quoted text 13 lines
> 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.

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

Reply by email

Ivo Steinmann
to Nataraj S Narayan: Luiz Got it compiled for arm after putting libsqlite in proper path. Getting this:- #…
Show quoted text 65 lines
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 On Fri, Nov 6, 2009 at 2:59 PM, Luiz Americo Pereira Camara wrote: > Nataraj S Narayan escreveu: > >> 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 >> >> >> > It's compiling here both with fpc224 and 251 but for win32. > > It seems a problem in the sqlite3 header for arm > > Luiz > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

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

Reply by email

Luiz Americo Pereira Camara
to Ivo Steinmann
Ivo Steinmann wrote 15 lines
Nataraj S Narayan schrieb: > Luiz > > Got it compiled for arm after putting libsqlite in proper path. > Getting this:- > > # ./testfunction > > ./testfunction: can't resolve symbol 'dl_iterate_phdr' > > 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.

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

Reply by email