I try to create a function with the same functionality as the TRANSLATE
function in Oracle, I have created function in Oracle and it works good but I have a problem when I try rewrite this code to Firebird. I get an error that 'expression evaluation not supported'. Why?
CREATE FUNCTION TRANSLATEE
(text varchar(10000),
toReplace varchar(10000),
replacePattern varchar(10000)
)
RETURNs VARCHAR(100)
aS
declare variable cut varchar(100);
declare variable i integer;
declare variable position1 varchar(100);
declare variable resultat varchar(100);
declare variable letter varchar(100);
declare variable lenght integer;
BEGIN
i = 1;
resultat ='';
lenght = char_length(:text);
while(i<lenght) do
begin
cut = substring(:text from i for 1);
position1 = position(:toReplace , cut);
if (position(:toReplace , cut) >0) then
begin
letter = substring(:replacePattern from position1 for 1);
resultat = resultat||''||letter;
end
else
begin
resultat = resultat ||''|| cut;
end
i = i+1;
end
RETURN resultat;
END;