Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Oracle For Fun
Mark Townsend wrote:
> Daniel Morgan wrote: >
> Do we have to do the function thing - what if we just return the valid > rows ? > > Then the whole thing can be done in a single SELECT. Something like (and > I haven't tested this, I don't have 10g at home on the Macs yet, but > this is close) > > Select * from table > where > REGEXP_LIKE(number,'^([[:digit:]]{3}-[[:digit:]]{3}-[[:digit:]]{4}|[[:digit:]]{10})$') > >
Worse yet Mark ... it isn't even valid:
SQL> CREATE TABLE t (
2 test VARCHAR2(20));
Table created.
SQL> INSERT INTO t VALUES ('123-45-6789');
1 row created.
SQL> COMMIT; Commit complete.
SQL> SELECT *
2 FROM t
3 WHERE
REGEXP_LIKE(test,'^([[:digit:]]{3}-[[:digit:]]{3}-[[:digit:]]{4}|[[:digit:]]{10})$');
no rows selected
Take a look at the "|[[:digit:]]{10}" ;-)
-- 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 Thu Jan 29 2004 - 03:08:33 CST