פונקציה בDB2 שהופכת מחרוזת
create function VFP.REVERSE(INSTR varchar(4000))
returns varchar(4000)
specific REVERSE
deterministic no external action contains sql
-- This function reverses a string.
begin atomic
declare REVSTR, RESTSTR varchar(4000) default '';
declare LEN INT;
if INSTR is NULL then
return NULL;
end if;
set (RESTSTR, LEN) = (INSTR, length(INSTR));
while LEN > 0 do
set (REVSTR, RESTSTR, LEN) = (substr(RESTSTR, 1, 1) concat REVSTR, substr(RESTSTR, 2, LEN - 1), LEN - 1);
end while;
return REVSTR;
end