Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Simple problem...
Afternoon T,
Unfortunately, I have had to roll my own function(s) to check - similar to the stuff below.
I normally use TO_NUMBER in its own begin/exception/end block and trap the exceptions. Problem with Integer numbers is that they are also floats (so to speak) so is_a_float('100') should return true as would is_an_integer('100').
In my version of IsAFloat, I allow the caller to specify whether integers are valid or not - the default is currently true, but can easily be changed to false.
IsANumber() is not anything I've had to write - just call IsAFloat('whatever', true) instead.
CREATE OR REPLACE FUNCTION IsAFloat(What IN VARCHAR2, IntIsFloat IN
BOOLEAN DEFAULT TRUE)
RETURN BOOLEAN
AS
CREATE OR REPLACE FUNCTION IsAnInteger(What IN VARCHAR2)
RETURN BOOLEAN
AS
Might be useful - maybe ?
Cheers,
Norman.
Tel: 0113 289 6265 Fax: 0113 289 3146 URL: http://www.Lynx-FS.com -------------------------------------
-----Original Message-----
From: Telemachus [mailto:tollg_at_tendwa.rns.net]
Posted At: Thursday, February 27, 2003 3:37 PM
Posted To: server
Conversation: Simple problem...
Subject: Simple problem...
But I can't find an easy solution.
For 817 without rolling your own PL/SQL func...
Is there a fast builtin way to do IS_A_NUMBER('STRING') or is_a_float()
or
is_an_integer()
i.e. given a string return true if the string represents a valid number
or
false. Or do most people trap an error from TO_NUMBER ?
T ... Received on Thu Feb 27 2003 - 11:05:24 CST