最近在学DB2,碰到自定义函数,但是有错误,网上查了,一脸懵逼。希望来个大神帮我补补课
CREATE OR REPLACE FUNCTION "F_GET_MAX_KEY" ("IC_NAME" VARCHAR(255) )
RETURNS VARCHAR(255)
BEGIN
/**
描述:根据序列生成表的流水主键
参数:IC_NAME:标识名(忽略大小写).
'SHORT':YYMMDD+序列SEQ_MAXKEY值;
'LONG':YYYYMMDDHHMISSFF3+序列SEQ_MAXKEY值;
其他:YYYYMMDDHHMISS+序列SEQ_MAXKEY值;
**/
DECLARE RESULTSTR VARCHAR (255) DEFAULT '';
SET IC_NAME = UPPER(IC_NAME) ;
IF UPPER(IC_NAME) = 'SHORT' THEN
SELECT TO_CHAR (CURRENT TIMESTAMP, 'YYMMDD') || LPAD (NEXTVAL FOR SEQ_MAXKEY, 4, '0')
INTO RESULTSTR
FROM SYSIBM.DUAL;
ELSEIF UPPER(IC_NAME) = 'LONG' THEN
SELECT TO_CHAR (CURRENT TIMESTAMP, 'YYYYMMDDHHMISSFF3') || LPAD (NEXTVAL FOR SEQ_MAXKEY, 4, '0')
INTO RESULTSTR
FROM SYSIBM.DUAL;
ELSE
SELECT TO_CHAR (SYSDATE, 'YYYYMMDDHHMISS') || LPAD (NEXTVAL FOR SEQ_MAXKEY, 4, '0')
INTO RESULTSTR
FROM SYSIBM.DUAL;
END IF;
RETURN RESULTSTR;
END;
在DBeaver 里运行sql脚本出现如下问题:
请问大神,怎么解决?