DB2 User-Defined FUNCTION 42601 Exception error DB2 version V8.1.3.160 Patch: 18 not to mention, go directly to code 42601 code create function ms. RENODE (nodecode varchar (10) returns varchar (10) language SQL NO EXTERNAL ACTION f1: BEGIN ATOMIC DECLARE V_FCODE VARCHAR (2); DECLARE V_LCODE VARCHAR (8 ); SET V_FCODE = SUBSTR (NODECODE, 1, 2); set lastcode = SUBSTR (NODECODE, 3, 8); IF (V_FCODE = '00') then set V_FCODE = '07 '; ELSEIF (V_FCODE = '01') then set V_FCODE = '08'; end if; RETURN V_FCODE | V_LCODE; END; after www.2cto.com is modified, the Code creates function ms without errors. RENODE (nodecode varchar (10) returns varchar (10) language SQL NO EXTERNAL ACTION f1: BEGIN ATOMIC DECLARE V_FCODE VARCHAR (2); DECLARE V_LCODE VARCHAR (8 ); SET V_FCODE = SUBSTR (NODECODE, 1, 2); SET V_LCODE = SUBSTR (NODECODE, 3, 8); IF (V_FCODE = '00') then set V_FCODE = '07 '; ELSEIF (V_FCODE = '01') then set V_FCODE = '08'; end if; RETURN V _ FCODE | V_LCODE; END; it seems that the semi-colon must be followed by one or half statements.