Results 1 to 3 of 3

Thread: sql:check

  1. #1
    Join Date
    Nov 2002
    Location
    germany
    Posts
    5

    Talking Unanswered: sql:check

    hi,
    i have a table bestellung:

    create table bestellung
    (bestellungsNr number(10) primary key,
    artikel_preis varchar2(30),
    gruppe_preis varchar2(30),
    check(artikel_preis = null or gruppe_preis = null)
    );
    and i want bei insert to have just 2 posibility:
    (not null,null,not null)
    (not null,not null,null)
    how can i do it?
    what must i change in my check ?
    thanks
    youssef

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: sql:check

    You cannot say "colname = null", since null is never equal to anything (not even to null!). Instead say "colname IS NULL".

    I believe your check constraint should be:

    CHECK( (artikel_preis IS NULL AND gruppe_preis IS NOT NULL)
    OR (artikel_preis IS NOT NULL AND gruppe_preis IS NULL) )

  3. #3
    Join Date
    Nov 2002
    Location
    germany
    Posts
    5

    Thumbs up Re: sql:check

    thanks very mutch

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •