SET SCHEMA DB2INST1;
SET CURRENT PATH = "SYSIBM","SYSFUN","SYSPROC","SYSIBMADM","DB2INST1";
CREATE FUNCTION DB2INST1.VARCHAR(CFLOAT DOUBLE)
RETURNS CHARACTER(30)
SPECIFIC DB2INST1.SQL091023140234200
LANGUAGE SQL
NOT DETERMINISTIC
READS SQL DATA
STATIC DISPATCH
CALLED ON NULL INPUT
EXTERNAL ACTION
INHERIT SPECIAL REGISTERS
BEGIN ATOMIC declare tint bigint default 0; declare TPOINT int default 0;
declare RESULT varchar(20);
declare aa decimal(12,2);
declare mpoint varchar
(3) default '0'
; set tint=bigint(cfloat);
set aa= round(cfloat-tint,2) ;
set TPOINT=int(aa*100); set mpoint= rtrim(char(TPOINT));
if TPOINT>=10 then
set RESULT=rtrim(char(tint))||'.'||mpoint;
else set RESULT=rtrim(char(tint))
||'.'||'0'||mpoint;
end if;
return RESULT ;
end;
------解决方案--------------------------------------------------------
想知道什么