Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Oracle For Fun

Re: Oracle For Fun

From: Tony <andrewst_at_onetel.net.uk>
Date: 29 Jan 2004 03:01:54 -0800
Message-ID: <c0e3f26e.0401290301.3265a09a@posting.google.com>


Daniel Morgan <damorgan_at_x.washington.edu> wrote in message news:<1075338777.438703_at_yasure>...
> Frank van Bortel wrote:
>
> > <g> COuld you make that a regular? I'd like that.
>
> My pleasure. I can't remember if I've done this one before ... but in
> the US telephone numbers with area code are always in the form ###-###-####.
>
> Write a simple function that will return a Boolean (True/False) as to
> whether something has the format of a valid telephone number with area
> code. It must check for the following:
>
> Three integers between 0 and 9
> Followed by a dash '-'
> Followed by three integers between 0 and 9
> Followed by a dash '-'
> Followed by four integers
> The length must be 12.
>
> Hint: When I run the following query:
> select * from user_source where name = <function_name>;
> it returns only 7 lines of code.

function valid_code ( p_code in varchar2 ) return boolean
is
begin
  return translate(nvl(p_code,'?'),'0123456789#','##########?') = '###-###-####'; end;

Only 6 lines ;0) Received on Thu Jan 29 2004 - 05:01:54 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US