Page 1 of 1

[SQLite3] Regexp problem

Posted: Thu 24 Mar 2011 08:37
by Stefan Padlo
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!

Posted: Thu 24 Mar 2011 13:40
by AlexP
Hello,

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

Posted: Fri 25 Mar 2011 18:04
by Stefan Padlo
Thanks for your reply. So all I can do right now is to wait looooonnnnggg time or use some wrapper :(

Posted: Mon 28 Mar 2011 06:48
by AlexP
Hello,

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

Posted: Mon 09 May 2011 11:18
by MamProblem
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!

Posted: Tue 10 May 2011 08:50
by AlexP
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'

}

Posted: Tue 10 May 2011 11:12
by MamProblem
Great job, thaks a lot!

Posted: Tue 10 May 2011 11:25
by AlexP
Hello,

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