0

I'm getting:

Error code 1022: Can't write; duplicate key in table 'eventrequest'

but I don't know why. Please help. Thank you. Below is my create statement for MySQL.

CREATE TABLE EventRequest
( EventNo VARCHAR(8) NOT NULL,
DateHeld DATE NOT NULL,
DateReq DATE NOT NULL,
FacNo VARCHAR(8) NOT NULL,
CustNo VARCHAR(8) NOT NULL,
DateAuth DATE,
Status ENUM('Approved', 'Denied', 'Pending'),
EstCost DECIMAL(15,2) NOT NULL,
EstAudience INT NOT NULL,
BudNo VARCHAR(8), 
CONSTRAINT PK_EVENTNO PRIMARY KEY (EventNo), 
CONSTRAINT FK_CUSTNO FOREIGN KEY (CustNo) REFERENCES Customer (CustNo),
CONSTRAINT FK_FACNO FOREIGN KEY (FacNo) REFERENCES Facility (FacNo),
CHECK(EstAudience > 0 ) );
Philip Olson
  • 4,662
  • 1
  • 24
  • 20
user2220115
  • 263
  • 6
  • 10
  • There's a good chance you're writing another row with an `EventNo` value that already exists. – AdamMc331 Oct 07 '15 at 16:10
  • 2
    maybe you are trying to insert a row with an `EventNo` that already exists in the `EventRequest` table? – Tom Mac Oct 07 '15 at 16:10
  • I'm not trying to insert a row. I trying to create a table and there are no fields duplicated as you can see. – user2220115 Oct 07 '15 at 18:10
  • Here are all the tables I'm trying to create. Do you think it might be something with the foreign key constraints? – user2220115 Oct 07 '15 at 18:23
  • Too many characters to post the tables. – user2220115 Oct 07 '15 at 18:25
  • Examine the other tables in the database. The constraint names must be unique and you may have already used the `FK_*` or `PK_*` names attempted with this table. http://stackoverflow.com/a/15723853/541091 – Michael Berkowski Oct 07 '15 at 19:34
  • Also take note [of the create table docs](https://dev.mysql.com/doc/refman/5.0/en/create-table.html)... MySQL will parse but _ignore_ the `CHECK` constraint. It will never actually take effect. "_The CHECK clause is parsed but ignored by all storage engines._" – Michael Berkowski Oct 07 '15 at 19:35
  • Thank you Michael! I posted too soon. I looked at the other tables and sure enough there was a constraint with the same name. – user2220115 Oct 08 '15 at 05:43

0 Answers0