Subject | UDF design would need array parameter |
---|---|
Author | Urs Liska |
Post date | 2005-01-20T15:12:08Z |
I have a stored procedure that has to split a string into its words.
To achieve this I wrote two UDFs (with Delphi): NumTokens(string) and
GetToken(index). First I get the number of words throught the first UDF
and then I loop up to this number to get the individual words.
The SP works something like this:
begin
j = fnumtokens(:string);
i = 0;
while (i < :j) do
begin
wort = fgettoken(:i, :string);
suspend;
i = :i + 1;
end
end
(i,j being integer variables, "wort" being the result field)
This works so far, but I think it is very inefficient, because I have to
pass the whole string each time I call GetToken (and I intend to use
the same on text blobs also).
From the nature of the task it would be best to pass the string to the
UDF once and get back an array of the words. But if I didn't completely
miss something this is not possible with firebird, isn't it?
My question is whether there is some way to solve the task more efficiently.
Any ideas?
Thank you
Urs
To achieve this I wrote two UDFs (with Delphi): NumTokens(string) and
GetToken(index). First I get the number of words throught the first UDF
and then I loop up to this number to get the individual words.
The SP works something like this:
begin
j = fnumtokens(:string);
i = 0;
while (i < :j) do
begin
wort = fgettoken(:i, :string);
suspend;
i = :i + 1;
end
end
(i,j being integer variables, "wort" being the result field)
This works so far, but I think it is very inefficient, because I have to
pass the whole string each time I call GetToken (and I intend to use
the same on text blobs also).
From the nature of the task it would be best to pass the string to the
UDF once and get back an array of the words. But if I didn't completely
miss something this is not possible with firebird, isn't it?
My question is whether there is some way to solve the task more efficiently.
Any ideas?
Thank you
Urs