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.2cto.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; 貌似能得到的結論:分號後面必須帶一個或半個語句。