| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to enforce a string format in a field??
"HansF" <news.hans_at_telus.net> a écrit dans le message de news:ML8qd.10132$VL6.3268_at_clgrps13...
> "Michel Cadot" <micadot{at}altern{dot}org> wrote:
>
> >
> > "Ramon F Herrera" <ramon_at_conexus.net> a écrit dans le message de
> > news:c9bc36ff.0411270245.4145eb43_at_posting.google.com...
> >> My database contains a field called 'SSN' whose
> >> contents should be obvious.
> >>
> >> Is there any way to constrain that field to the
> >> following format: ddd-dd-dddd? That is: if there is
> >> an attempt to insert a value that doesn't have 9 digits
> >> with the hyphens in the proper places, the record should
> >> be rejected.
> >>
> >> Or is this something that I should check before inserting
> >> the data into the table (for instance, making sure that
> >> the *.dat file only contains proper SSN values)??
> >>
> >> TIA,
> >>
> >> -Ramon F Herrera
> >
> > alter table mytable add constraint myct
> > check (regexp_like(myfield,'^[:digit:]{3}-[:digit:]{2}-[:digit:]{4}$'));
> >
>
> Good one Michael. But isn't there a version restriction that we should tell
> the OP? (Regardless that the OP didn't tell us what version is relevant.)
>
> /Hans
Yes, this is only available in 10g but i didn't say it because the OP seems to think it is not important to post his release.
-- Regards Michel CadotReceived on Sun Nov 28 2004 - 00:18:47 CST
![]() |
![]() |