On Mar 11, 2008, at 3:02 PM, [EMAIL PROTECTED] wrote:

>
>
>    OK Dan, you have the solution.  The count was including the
> terminating NULL char.  Making it not include the NULL char fixed
> the problem.
>
>    Another question:  For an empty result, should I return 0 or -1?
> And should the string be NULL or "" ?  Bear in mind that its an empty
> result - not a NULL result.

   sqlite3_result_text(pContext, "", 0, SQLITE_STATIC)

will work. You could also pass -1 instead of 0 (-1 means use
strlen() or its utf-16 equivalent for result_text16()) to
discover the number of bytes in the string argument.

Passing NULL as the second parameter would not work. That would
result in the SQL user function returning an SQL NULL, not a
zero length string.

Dan.



>
>    Thanks a million
> -brett
>
>    Quoting Dan Kennedy >
>
>>
>>   I'm trying to get the concat operator to work with my
> user-defined
>> function.  This works fine:
>>
>>   SELECT UPPER(FirstName) || ' ' || UPPER(LastName) FROM  Employees
>>
>>   But this doesn't work:
>>
>>   SELECT FORMAT_DATE(login_time) || ' ' || FORMAT_TIME(login_time)
>> FROM Sessions
>>
>>   I get only the formatted date - missing the formatted time.
>> FORMAT_DATE is my own user-defined function that returns text data
>> type.
> When you call sqlite3_result_text() to return the result, does your
> result string include a nul-terminator character? If so, that byte
> should not be included in the "number of bytes" parameter passed
> to result_text(). i.e. if you were doing:
>
> sqlite3_result_text(pContext, "abc", 4, ...)
> you might get the result you are describing.
> Dan.
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to