[SQLite3] Regexp problem

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Stefan Padlo
Posts: 5
Joined: Wed 23 Mar 2011 23:02

[SQLite3] Regexp problem

Post by Stefan Padlo » Thu 24 Mar 2011 08:37

Hi all!

I have a problem with the REGEXP function using SQLite. It says that there's no function such regexp.
My question is : how to implement sqlite_create_function with C++ Builder + UniDAC?


Thanks!

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Thu 24 Mar 2011 13:40

Hello,

Now you can't add user functions to SQLite.
We plan to add such possibility in the next version.

Stefan Padlo
Posts: 5
Joined: Wed 23 Mar 2011 23:02

Post by Stefan Padlo » Fri 25 Mar 2011 18:04

Thanks for your reply. So all I can do right now is to wait looooonnnnggg time or use some wrapper :(

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Mon 28 Mar 2011 06:48

Hello,

We plan to release the new version with support for user functions next month.

MamProblem
Posts: 13
Joined: Mon 09 May 2011 11:11

Post by MamProblem » Mon 09 May 2011 11:18

Hi!

I couldn't find any way to create user-defined regexp function in my application. I use RadStudio XE - C++ Builder + SQLITE3 + UniDAC version 3.70. Please give me some tips to do that.
Thanks!

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Tue 10 May 2011 08:50

Hello,

Below is a small sample demonstrating how to use SQLite user functions in C+Builder:

Code: Select all

// defining user function
// where 
// InValues - Input array values of variant
// InValues_Siz - for compatibility (is not used)
// return - return value of variant
Variant __fastcall Reverse(Variant *InValues, const int InValues_Size)
{
// your own function body, for example
	return ReverseString(VarToStr(InValues[0]));
}

void __fastcall TForm1::UniConnection1AfterConnect(TObject *Sender)
{
// Registering user function
// where:
// UniConnection1 - pointer to TUniConnection
// "REVERSE" - name of user function
// 1 - number of user function parameters
// Reverse - pointer to user function

	TLiteUtils::RegisterFunction(UniConnection1,"REVERSE",1,Reverse);
}

// Using user function
void __fastcall TForm1::Button1Click(TObject *Sender)
{
	UniQuery1->SQL->Text = "select REVERSE('ABCD')"; 
	UniQuery1->Open(); //result 'DCBA'

}

MamProblem
Posts: 13
Joined: Mon 09 May 2011 11:11

Post by MamProblem » Tue 10 May 2011 11:12

Great job, thaks a lot!

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Tue 10 May 2011 11:25

Hello,

Glad to see that the problem was solved. If you have any other questions, feel free to contact us.

Post Reply