0

I am trying to define a new domain "rating_int" that I would be able to use in the table "Review". Anytime I try to execute this query, it returns this message:

ERROR: column "rating_int" does not exist

********** Error **********

ERROR: column "rating_int" does not exist

SQL state: 42703

I followed the exact same code format as the postgresql example and I do not know why my code is returning an error.

CREATE DOMAIN rating_int AS INTEGER
CHECK(rating_int > 0 AND rating_int <=10);

CREATE TABLE Review
(
    paper_id INTEGER,
   rv_email VARCHAR(55)     NOT NULL,
   reccomendation TEXT,
   a_comments TEXT,
   c_comments TEXT,
   technical_merit rating_int,
   readability rating_int,
   orginality rating_int,
   relevance rating_int,
   PRIMARY KEY(paper_id, rv_email),
   FOREIGN KEY(paper_id) REFERENCES Paper
   ON DELETE RESTRICT ON UPDATE CASCADE,
   FOREIGN KEY(rv_email) REFERENCES Reviewer
   ON DELETE SET NULL   ON UPDATE CASCADE
   );

1 Answer 1

1

You use value, not the name of the domain. Like this:

CREATE DOMAIN rating_int AS INTEGER
    CONSTRAINT chk_rating_int CHECK (value > 0 AND value <= 10);

You don't actually need to give the constraint a name -- your error was rating_int instead of value. So this works:

CREATE DOMAIN rating_int AS INTEGER
    CHECK (value > 0 AND value <= 10);

However, I think it is a good idea to give constraints names.

Also, you might want to make the type a smallint or decimal(2), if you want to save on space.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, my query executed with no problems. Can I ask why am I expected to use value rather than the name of the domain?
@stargazer . . . That is how the syntax is defined.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.