在Oracle中判断某个字段的值是否为数字


一表travel_line,里面有pub_price, trade_price两字段,类型为varchar,需要把里面为纯数字的内容提取出来,写个函数来处理:

  1. create or replace function Isnumber(P_column in varchar2) return number is  
  2.   l_t number;  
  3. begin  
  4.   l_t := to_number(P_column);  
  5.   return 1;  
  6. exception  
  7.   when others then  
  8.     return 0;  
  9. end;  

使用

select t.pub_price, t.trade_price, t.* from travel_line t where  Isnumber(t.pub_price) = 1 and Isnumber(t.trade_price) = 1

相关内容