I’ve got this code (just an excerpt)…
CREATE TABLE "Degree"
(
ippp_code character varying(5) CONSTRAINT four_or_five_chars_only CHECK (ippp_code >= 4 OR ippp_code <= 5) NOT NULL
)
What i’m try do is make the ippp_code a maximum of 5 characters or a mininum of 4 characters. So you can only enter 4 or 5 characters.
When I run the code I get an error message saying…
ERROR: operator does not exist: character varying >= integer HINT:
No operator matches the given name and argument type(s). You might
need to add explicit type casts.*** Error ***
ERROR: operator does not exist: character varying >= integer SQL
state: 42883 Hint: No operator matches the given name and argument
type(s). You might need to add explicit type casts.
I wondering can I use the constraint I set using character varying? Also can I get a correction on the code?
You were trying to check that the value of ippp_code was between 4 and 5, not the length.