Hi everyone. I've tried to write a function in db2 but it wouldnt compile. I've tried to compile one of the examples from the db2 help, but i get the following error:
Quote:
During SQL processing it returned:
SQL0104N An unexpected token "''" was found following "archar(4000) default".
Expected tokens may include: "END-OF-STATEMENT". LINE NUMBER=6.
SQLSTATE=42601
|
Any ideas??...
The code tested was:
Code:
create function tms.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