![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Is it possible in ASA 7 and beyond to have a column check constraint that uses another column in the same table in the criteria? That is something like (constraint on column col1): CHECK (CASE col1 WHEN 'Y' and (col2 IS NULL or col3 IS NULL) THEN FALSE ELSE TRUE ) The reason I'd like to do this is to help debug a problem in our code which the developers have not been able to pin point, that is, a condition that they are not able to find on their own, I'd like the database to catch it and not allow a certain record format. I tried the above logic in a alter table check statement, but the database doesn't like the condition, and I haven't been able to find a related example in the ASA manual. Thanks. Phil |
#3
| |||
| |||
|
|
Is it possible in ASA 7 and beyond to have a column check constraint that uses another column in the same table in the criteria? That is something like (constraint on column col1): CHECK (CASE col1 WHEN 'Y' and (col2 IS NULL or col3 IS NULL) THEN FALSE ELSE TRUE ) The reason I'd like to do this is to help debug a problem in our code which the developers have not been able to pin point, that is, a condition that they are not able to find on their own, I'd like the database to catch it and not allow a certain record format. I tried the above logic in a alter table check statement, but the database doesn't like the condition, and I haven't been able to find a related example in the ASA manual. Thanks. Phil |
#4
| |||
| |||
|
|
You need to specify your restriction as a table constraint and not a column constraint. Something like the following as a table constraint should do what you want: CHECK ( (col1 <> 'Y') or ( col2 is not null and col3 is not null )) -anil "Phil Kaufman" <philk (AT) dbcsmartsoftware (DOT) com> wrote in message news:3fd093aa$1 (AT) forums-1-dub (DOT) .. Is it possible in ASA 7 and beyond to have a column check constraint that uses another column in the same table in the criteria? That is something like (constraint on column col1): CHECK (CASE col1 WHEN 'Y' and (col2 IS NULL or col3 IS NULL) THEN FALSE ELSE TRUE ) The reason I'd like to do this is to help debug a problem in our code which the developers have not been able to pin point, that is, a condition that they are not able to find on their own, I'd like the database to catch it and not allow a certain record format. I tried the above logic in a alter table check statement, but the database doesn't like the condition, and I haven't been able to find a related example in the ASA manual. Thanks. Phil |
![]() |
| Thread Tools | |
| Display Modes | |
| |