Subject Re: [ib-support] Pass query parameters as argument for UDF. Does it work or not?
Author Raymond Kennington
Andrew Guts wrote:
> Hello all,
> Please clarify: is it possible to pass query parameter to UDF ?
> According the document "Firebird v1 Closed Bugs"
> SF ID 409769
> it is possible. But I have "unknown data type" error. Why so?
> I am writing a searching UDF for using with search service of our website.
> How to pass search pattern to the function? Now I have to build static
> SQL query on the fly,
> but it imposes considerable restrictions to search pattern.
> For example I have to trim both type of quotes, percent symbol and so on.
> I'm thinking about wrapping the query by stored procedure. Is it right?
> /* double str_match(unsigned char* text, unsigned char* pattern); */
> CSTRING(256), CSTRING(256)
> ENTRY_POINT 'str_match' MODULE_NAME 'fe_udf';
> Usage :
> select id, description, strmatch(description, :pattern) as k
> from products where legacy = 0 and strmatch(description, :pattern) >=
> :mfactor
> order by 3 desc, 2

I think :pattern must be assigned to a string variable in the stored procedure
first and then use that variable in the SELECT statement.
Raymond Kennington
Programming Solutions
W2W Team B