Re: PL/SQL

From: Alex Heney <heneya_at_entcf3.agw.co.bt.uk>
Date: 1997/02/20
Message-ID: <330C6D95.362A_at_entcf3.agw.co.bt.uk>#1/1


sam s wrote:
> i'm interested to know if there is a procedure or function
> to check for a value and prompt an error msg if the value
> does not fall in the range of A-Z and 0-9, leaving out all
> the special characters?

No there is no such function, but you can easily write one yourselves (as I imagine everybody else who uses ORACLE has!!).

This function should look something like:

FUNCTION alphanumeric (x IN VARCHAR) RETURN BOOLEAN IS

  FOR i IN 1 .. LENGTH(x)

    IF UPPER(substr(x,i,1)) NOT BETWEEN 'A' AND 'Z' AND

       substr(x,i,1) NOT BETWEEN '0' and '9'     THEN
       Return(FALSE);
    END IF;
  END LOOP;
  Return(TRUE);

END alphanumeric;

-- 
The above posting represents the personal opinions of the author and
is not to be taken as official (or unofficial) policy or opinions of 
his employer.

Alex Heney, Living in the Global Village.
Received on Thu Feb 20 1997 - 00:00:00 CET

Original text of this message