我创建了一个DB2用户定义的函数。该函数创建了锁,整个db2 studio在创建时挂起并显示-904消息。必须关闭并重新启动DB2。
CREATE FUNCTION LOOP_FN (CUSTOM_DIVISION_GROUP VARCHAR(255), COMPANY VARCHAR(255), LOCATION VARCHAR(255),COMD VARCHAR(255),BASIS VARCHAR(1))
RETURNS VARCHAR(30)
BEGIN
DECLARE COUNT_VAR INT;
DECLARE j int;
DECLARE NAMES_VAR varchar(30);
DECLARE myTemp varchar(30);
DECLARE CustomGroup varchar(30);
SET CustomGroup = '';
SET j = 0;
SET COUNT_VAR = LENGTH(CUSTOM_DIVISION_GROUP)-LENGTH(REPLACE(CUSTOM_DIVISION_GROUP,',',''));
IF BASIS = 'N' THEN
WHILE j <= COUNT_VAR DO
SET NAMES_VAR = (SELECT VALUE_1 FROM TABLE(SPLIT_PARAMS(CUSTOM_DIVISION_GROUP,',',COUNT_VAR+2)) WHERE ID_1=j+1);
IF (LOCATE(':', NAMES_VAR)>0) THEN
SET myTemp = SUBSTR(NAMES_VAR,1,LOCATE(':', NAMES_VAR)-1);
ELSE
SET myTemp = NAMES_VAR;
END IF;
IF LOCATE(COMPANY||LOCATION,NAMES_VAR) > 0 THEN
SET CustomGroup = myTemp;
END IF;
SET j = j + 1;
END WHILE;
ELSEIF BASIS = 'Y' THEN
WHILE j <= COUNT_VAR DO
SET NAMES_VAR = (SELECT VALUE_1 FROM TABLE(SPLIT_PARAMS(CUSTOM_DIVISION_GROUP,',',COUNT_VAR+2)) WHERE ID_1=j+1);
IF NAMES_VAR = COMPANY||LOCATION||COMD||'Y' THEN
SET CustomGroup = 'True';
END IF;
IF NAMES_VAR = COMPANY||LOCATION||COMD||'N' THEN
SET CustomGroup = 'False';
END IF;
SET j = j + 1;
END WHILE;
END IF;
RETURN CustomGroup;
END@
任何人都可以帮我解决问题并创建功能。我可以知道函数中的哪些语句会导致此问题。