Subject RE: [firebird-support] UDF Problem
Author Kevin Day Programming
I have written other udfs and never had a connection lost error before.

Any thoughts appreciated.

--------------------------------------------------------------------

select ProperCaseString(namefirst) from members where id = 428

If I do select without the ProperCaseString() Ok so problem is UDF call.

--------------------------------------------------------------------

External Function which when tested by direct call to function in dll,
returns a proper case string.

DECLARE EXTERNAL FUNCTION PROPERCASESTRING
VARCHAR(80) CHARACTER SET NONE
RETURNS VARCHAR(80) CHARACTER SET NONE
ENTRY_POINT 'fn_ProperCaseString' MODULE_NAME 'strudf';

----------------------------------------------------------------------

and dll code .cpp

String __stdcall fn_ProperCaseString(String CheckString)

OK I have any experience writing udfs in c or c++, only Delphi, what works
for me use using the Delphi type pchar which is equivalent to the old
pointer to char or char array in c. In Firebird / interbase instead of
declaring the data types as varchar as you have try cstring instead. Also
are you are aware of memory issues and returning strings. A good article
aimed at Delphi users can be found in a couple of places but one place is:


http://codecentral.borland.com/codecentral/ccweb.exe/getfile?id=17065&filena
me=3130%20-%20Building%20UDF%20Libraries.html

This explains some of the issues (the issues are dependant upon your
compiler. There is an example of a udf in c also but the delphi example are
easy to port to C. Looking at your code you may end up with memory leaks.

Kevin.


[Non-text portions of this message have been removed]