0
votes
CREATE TABLE Representatives(

ID NUMBER(4) NOT NULL PRIMARY KEY,

State CHAR(2) NOT NULL,

District NUMBER NOT NULL CHECK(District>=1 AND District<=30),

Party VARCHAR2(30),

LastName VARCHAR2(20),

Firstname VARCHAR2(20),

StartOfTerm DATE,

EndOfTerm DATE,

SenRank VARCHAR2 CHECK(senRank IN ('junior', 'senior')),

Gender CHAR(1) CHECK(Gender IN ('M', 'F')),

Birthdate DATE,

FOREIGN KEY(State) REFERENCES States(State),

FOREIGN KEY(Party) REFERENCES Parties(Party)

);

Error report - ORA-00906: missing left parenthesis 00906. 00000 - "missing left parenthesis" *Cause:
*Action:

Can't find the error can someone please point me to the right direction

2

2 Answers

0
votes

I think the issue is a missing length on varchar2():

CREATE TABLE Representatives (
    ID NUMBER(4) NOT NULL PRIMARY KEY,
    State CHAR(2) NOT NULL,
    District NUMBER NOT NULL CHECK(District>=1 AND District<=30),
    Party VARCHAR2(30),
    LastName VARCHAR2(20),
    Firstname VARCHAR2(20),
    StartOfTerm DATE,
    EndOfTerm DATE,
    SenRank VARCHAR2(255) CHECK (senRank IN ('junior', 'senior')),
    -----------------^
    Gender CHAR(1) CHECK (Gender IN ('M', 'F')),
    Birthdate DATE,
    FOREIGN KEY (State) REFERENCES States(State),
    FOREIGN KEY (Party) REFERENCES Parties(Party)
);

Here is a db<>fiddle, without the foreign key declarations.

0
votes

SenRank VARCHAR2 CHECK(senRank IN ('junior', 'senior')),

You forgot to mention the length of VARCHAR2 data type in the SenRank column. Add an appropriate length and it should work just fine:

SenRank VARCHAR2(25) CHECK(senRank IN ('junior', 'senior'))