Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Test for a numeric value

Status
Not open for further replies.

SpiritOfLennon

IS-IT--Management
Oct 2, 2001
250
GB
Hi,
I need to test a field in PL/SQL cand if the second through to the seventh characters are all numeric the test should pass else it should fail. I remember a thread related to this a few weeks ago with a neat solution, but I can't for the life of me find it. If any one could point me in the right direction I'd appreciate it. SOL
I'm only guessing but my guess work generally works for me.
 
FUNCTION nuber_test (p_string IN VARCHAR2)
RETURN BOOLEAN IS
l_test NUMBER;
BEGIN
l_test := To_Number(Substr(p_string,2,6));
Return TRUE;
EXCEPTION
WHEN OTHERS
THEN
Return FALSE;
END;

Call the function. If it returns TRUE chars 2 to 7 are numeric.
 
Okay cool, thanks. Now how do I test the boolean returning from my function is it number_test(field) = 'TRUE'
SOL
I'm only guessing but my guess work generally works for me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top