• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

isNumeric???

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I want to check my Input field, whether it is numeric or not. There seems to be no such function in Oracle 8i. If it's not numeric, I get the message 'invalid number', so I need to check before inserting into database. I can use the 'translate'-function, but that seems too complicated!
Thanx for helping,
Lars
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there
Write a stored pl/sql function to check it as described below:
<br>
create or replace function
isNumeric ( i_value_to_check varchar2) return number is
v_dummy number;
begin
v_dummy := to_number( i_value_to_check);
return 1; -- it's number
exception
when others then
return -1; -- it's invalid
end isNumeric;
/
<br>
regards,
 
Lars Vegas
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for helping, but I wasn't looking for a new function. I hoped for a function that is already implemented in Oracle.
I did it this way now:
"( ( decode ( trim
( translate
( translate( "+checkValue+", ' ', 'x')"
+ ", '0123456789', ' ' ) ) "
+ ", '', '0'"
+ ", '.', '0'"
+ ", '1' ) ) "
+ " = '1' )"
 
I have a knack for fixing things like this ... um ... sorry ... here is a consilitory tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic