CONVERTSYMBOLS

Themen rund um den praktischen Einsatz von Firebird. Fragen zu SQL, Performance, Datenbankstrukturen, etc.

Moderator: thorben.braun

Antworten
sroland
Beiträge: 4
Registriert: Fr 27. Jul 2018, 08:38

Fr 27. Jul 2018, 09:42

Ersatz für F_CONVERTSYMBOLS
Frei nach meiner Device lasst die Datenbank tun was sie alleine kann

Code: Alles auswählen

create or alter procedure CONVERTSYMBOLS (
    input varchar(1024),
    INP_SEARCH varchar(100),
    INP_REPLACE varchar(100))
returns (
    RESULT varchar(1024))
AS
declare variable icount Integer;
declare variable v_search Char(1);
declare variable v_replace Char(1);
begin
  result = Coalesce(input,'');
  inp_search = Coalesce(inp_search,'');
  inp_replace = Coalesce(inp_replace,'');

  if (char_length(inp_search) = 0) then exit;
  icount = 1;
  while (iCount <= char_length(inp_search)) do
  begin
    v_search = substring(inp_search from  iCount for 1);
    if (iCount <= char_length(inp_replace)) then
      v_replace = substring(inp_replace from  icount for 1);
    else
      v_replace = '';
    input = replace(input,v_search, v_replace);
    iCount = icount+1;
  end
  result = input;
  suspend;
end
Test
"SELECT * FROM CONVERTSYMBOLS('(1+12)-123*1+2=3', '123', 'abc')"

gruß Roland
lg Roland Siegel
s-plus GmbH
schreiner-plus.de
Antworten