Guillaume,
This is my callback function. As Martin suggested, it's defined
outside of any class. It looks to me like you're not passing the
correct parameters tothe create function.
static void sqlite3_regexp(sqlite3_context *pDB, int argc, sqlite3_value **argv)
{
CDBSqLite3* pThis =
reinterpret_cast<CDBSqLite3*>(sqlite3_user_data(pDB));
if(argc!= 2 )
{
sqlite3_result_int(pDB, 0);
return;
}
bla bla
}
if(sqlite3_create_function(m_pDb, "REGEXP", 2, SQLITE_UTF8,
this,sqlite3_regexp, NULL, NULL) != SQLITE_OK)
{
assert(0);
}
Wednesday, December 17, 2008, 12:37:15 PM, you wrote:
ME> Hi,
ME> i suspect that you problem is the class MyClass.
ME> Try to define your function "ScorePosition" as a C-function outside of a
ME> class.
ME> Martin
ME> Guillaume Schub wrote:
>> Hi everyone,
>>
>> I have spent nearly one day on this already with no success. I am
>> currently trying to create some custom function on a SQLite3 database.
>>
>> What I did (just to test):
>>
>> sqlite3_create_function(m_pDB, "ScorePosition", "ScorePosition", 8,
>> SQLITE_ANY, NULL, &ScorePosition, NULL, NULL);
>>
>> class MyClass
>> {
>> ...
>> static void ScorePosition(sqlite3_context *pContext,int argc,
>> sqlite3_value** argv);
>> ...
>> };
>>
>> void MyClass::ScorePosition(sqlite3_context *pContext,int argc,
>> sqlite3_value** argv)
>> {
>> ...
>> }
>>
>> SELECT ScorePosition(1, 2, 3, 4, 5, 6, 7, 8) FROM MyTable;
>>
>> No the problem is that the callback is called, but pContext is always
>> NULL, argc a fancy value, and argv always the same value (like
>> 0x0012f2d4)
>>
>> What am I missing here ?
>>
>> Guishu
>> _______________________________________________
>> sqlite-users mailing list
>> [email protected]
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>>
>>
--
Best regards,
Teg mailto:[email protected]
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users