CREATE FUNCTION vchar( shu decimal , F_ID VARCHAR(20))
sw varchar(30) ;
BEGIN ATOMIC
select
replace(replace(replace(replace(replace(replace(replace(replace(replace(A.DivisionLineValue, ' 000000000', ''), ' 00000000', ''), ' 0000000', ''), ' 000000', ''), ' 00000', ''),' 0000',''),' 000',''),' 00',''),' 0','')
into sw
from (
select ' ' || case char(shu)
when '0999999999.00 '
then F_ID
else char(shu)
end as DivisionLineValue
from sysibm.sysdummy1
) as A
RETURN l_type;
END ;
出现 104 错误 我对DB2 的语法不 熟悉 希望 高人指点 下 改成什么样 是正确的
------解决方案--------------------------------------------------------
- SQL code
CREATE FUNCTION Test (shu decimal , F_ID VARCHAR(20)) RETURNS varchar(20) LANGUAGE SQL CONTAINS SQL NO EXTERNAL ACTION DETERMINISTIC return ( case when char(shu) = '0999999999.00' then F_ID else replace(replace(replace(replace(replace(replace(replace(replace(replace(' ' || char(shu), ' 000000000', ''), ' 00000000', ''), ' 0000000', ''), ' 000000', ''), ' 00000', ''),' 0000',''),' 000',''),' 00',''),' 0','') end);