我想在 DB2 中创建和部署这个功能,但我卡住了。请你帮助我好吗?
干杯,
我的功能代码:
CREATE FUNCTION getID(NameIn VARCHAR(255),versionIn varchar(255))
RETURNS varchar(12)
NOT DETERMINISTIC
LANGUAGE SQL
MODIFIES SQL DATA
NO EXTERNAL ACTION
BEGIN
declare IDOut varchar(12);
set IDOut = (select mID
from mIDHolder
where mName = NameIn and version = versionIn);
IF mappingIDOut IS NULL THEN
set IDOut = Hex(GENERATE_UNIQUE());
insert into mIDHolder VALUES (IDOut,NameIn,versionIn);
END IF;
RETURN IDOut;
END
这是 mIDHolder 表 DDL
CREATE TABLE "V"."MIDHOLDER" (
"MID" VARCHAR(12) FOR SBCS DATA NOT NULL,
"MNAME" VARCHAR(255) FOR SBCS DATA WITH DEFAULT NULL,
"VERSION" VARCHAR(255) FOR SBCS DATA WITH DEFAULT NULL
)