| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Verifying a variable only contains letters and not punctuation...
Hi Bryan
I think to find punctuation as you describe the only way is to loop through your string checking each character.
The second question is easier. I assume you want to check whether a char variable contains only a valid number. A number datatype can only contain a number.
FUNCTION IS_NUMBER(p_String VARCHAR2)
RETURN BOOLEAN
IS
Dummy NUMBER;
BEGIN
Dummy := to_number(p_String);
RETURN TRUE;
EXCEPTION
WHEN VALUE_ERROR THEN
RETURN FALSE;
END;
Example of usage:
IF is_number(my_string) THEN
my_number := to_number(my_string);
END IF;
If you are interested you'll find this and other useful
PL/SQL stuff on the Oracle Utilities Page of my web site
(http:/members.aol.com/jomarlen)
John
>Is there a way in PL/SQL to check for all punctuation marks such as
>commas, periods, etc. I will not know what the punctuation mark will be
>therefore, I cannot really use the REPLACE(variable, ',', '') function.
>I would rather use something more reliable. Is there something that
>PL/SQL has to do this?
>
>Also, if I wanted to check that a variable of type NUMBER was only
>numbers, how could I do that?
>
>--
>************************************
> Bryan J. Gentile
> Consultant
> Business Data Services, Inc.
> Glastonbury, CT 06033
> Phone: (860)633-3693 (ext. 3025)
> Vmail: (ext. 6030)
>************************************
>
>
>
>
>
>
>
>
>
Received on Fri Oct 24 1997 - 00:00:00 CDT
![]() |
![]() |