DB2自定义函数42601异常错误
DB2自定义函数42601异常错误
DB2版本V8.1.3.160 补丁:18
不多说,直接上代码
42601代码
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;
www.zzzyk.com
修改后,代码
无差错代码
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
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;
貌似能得到的结论:分号后面必须带一个或半个语句。