Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Quiz
Kenneth wrote:
>Oops... The function below does in fact accept
>'(((() 999-9999' as a phone number. We thus also have to check that
>the number of '(',')','-' and ' ' is exactly one respectively :
>
>
>create or replace function check_number(number in varchar2) return
>boolean
>is
>begin
> return (
> number like '(___) ___-____'
> and ltrim(translate(number,'()- 0123456789',' ')) is null
> and length(translate(number,'z() -','z')) = 10 );
>end check_number;
>
>
>- Kenneth Koenraadt
>
>On Sat, 25 Oct 2003 14:06:51 GMT, Kenneth Koenraadt wrote:
>
>
>
I responded to the top one by mistake ... my above response was intended
for this posting.
Do a slight variation of the above and you can do it in a single line
without checking the
length.
-- Daniel Morgan http://www.outreach.washington.edu/ext/certificates/oad/oad_crs.asp http://www.outreach.washington.edu/ext/certificates/aoa/aoa_crs.asp damorgan_at_x.washington.edu (replace 'x' with a 'u' to reply)Received on Sat Oct 25 2003 - 11:08:35 CDT