ERROR 1136 PROCEDURES + INSERT + FOREIGN KEY

Asked

Viewed 41 times

0

This error is appearing and I am not managing to solve it:

ERROR 1136 PROCEDURES + INSERT + FOREIGN KEY

The number of parameters is equal. Did I do something wrong on constraint?

Follows the Code:

CREATE TABLE FILMES(IDFILMES INT PRIMARY KEY AUTO_INCREMENT, 
                    NOME VARCHAR(45) NOT NULL,
                    GENERO VARCHAR(45) NOT NULL,
                    AVALIACAO ENUM('RUIM', 'REGULAR', 'BOA') NOT NULL,
                    ANO VARCHAR(4) NOT NULL
);                    
                    
CREATE TABLE ATOR(IDATOR INT PRIMARY KEY AUTO_INCREMENT,
                    NOME VARCHAR(45) NOT NULL,
                    SEXO ENUM('M','F') NOT NULL,
                    PERSONAGEM VARCHAR(45) NOT NULL,
                    TIPO VARCHAR(45) NOT NULL,
                    FK_FILMES INT,
                    
                    FOREIGN KEY(FK_FILMES)
                    REFERENCES FILMES(IDFILMES)
);

DELIMITER #

CREATE PROCEDURE CAD_ATOR(P_NOME VARCHAR(45),
                            P_SEXO ENUM('M','F'),
                            P_PERSONAGEM VARCHAR(45),
                            P_TIPO VARCHAR(45),
                            FK_FILMES INT)
BEGIN 
    INSERT INTO ATOR VALUES(P_NOME, P_SEXO, P_PERSONAGEM, P_TIPO, FK_FILMES);
END
#

CALL CAD_ATOR('BRADLEY COOPER', 'M', 'PHIL', 'PRINCIPAL', 1)#  -> AQUI ACUSA O ERRO!!!!!
  • There has to be a movie with IDFILMES 1, this is what FK tests. In this case "If You Drink, Don’t Get Married!" ...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.