oracle如何判断一个数是不是整数呢?比如3.000和3.100,如何筛选出来3.100
4个回答
展开全部
select decode(instr('1', '.') + sign('1'), 1, 1, 0) from dual;
返回1是整数,否则不是
create or replace function f_isnumeric(cnt varchar2) return number asres number; flag number; beginif cnt is
null thenreturn 0;
end if; select to_number(cnt) into res from dual; select decode(instr(res, '.') + sign(res), 1, 1, 0) into flag from dual; if flag = 1 thenreturn 1; else return 0;
end if;
exception
when others then return 0;
end;
返回1是整数,否则不是
create or replace function f_isnumeric(cnt varchar2) return number asres number; flag number; beginif cnt is
null thenreturn 0;
end if; select to_number(cnt) into res from dual; select decode(instr(res, '.') + sign(res), 1, 1, 0) into flag from dual; if flag = 1 thenreturn 1; else return 0;
end if;
exception
when others then return 0;
end;
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
SELECT C_NUM,
CASE
WHEN C_NUM - TRUNC(C_NUM) = 0 THEN
'整数'
ELSE
'非整数'
END
FROM (SELECT 3.000 C_NUM
FROM DUAL
UNION ALL
SELECT 3.100
FROM DUAL
UNION ALL
SELECT 4.400
FROM DUAL
UNION ALL
SELECT 5.400
FROM DUAL
UNION ALL
SELECT 5.000 FROM DUAL)
CASE
WHEN C_NUM - TRUNC(C_NUM) = 0 THEN
'整数'
ELSE
'非整数'
END
FROM (SELECT 3.000 C_NUM
FROM DUAL
UNION ALL
SELECT 3.100
FROM DUAL
UNION ALL
SELECT 4.400
FROM DUAL
UNION ALL
SELECT 5.400
FROM DUAL
UNION ALL
SELECT 5.000 FROM DUAL)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
trunc(3.1)=3.1相等是正数,否则是小数。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询