What are the challenges you face when working across database platforms? Take the survey
Options

Try to resolve this

smuxsmux Posts: 2
edited September 9, 2005 11:48AM in SQL Compare Previous Versions
Hello, try to resolve this:

There are a Table, example: TBL_1 whit three fields:

TBL_1
Fld1,
Fld2,
Fld3

How to introduce a constraint that do that one and only one of the fields have got data,
the other fields have to be empty.

Ex correct:

TBL_1 --> NULL,NULL,1
NULL,1,NULL
1,NULL,NULL

Ex incorrect (this haven't to happened):

TBL_1 --> 1,1,NULL
1,1,1
NULL,NULL,NULL

Comments

  • Options
    Sorry I can't think of anything.

    You'd more than likely have to program this into the logic of the application that's inserting the data, something like

    If Fld1!=NULL XOR Fld2!=NULL XOR Fld3!=NULL Then...
This discussion has been closed.