我有以下存储过程,我这里有两个表,电影和导演。当创建或添加新电影时,两者都需要更新。您如何处理存储过程中的 FK?在这种情况下,FK 是director_id
。它是一个主键,Director
但是一个 FKMovie
我需要像这样指定它两次吗?我收到冲突错误
CREATE PROCEDURE Book_Book_Creation
@Book_id_arg DECIMAL(12),
@author_id_arg DECIMAL(12),
@type_id_arg DECIMAL(12),
@title_arg VARCHAR(64), -
@copyright_arg DECIMAL(4),
@dauthor_id_2_arg DECIMAL(12),
@author_fname_arg VARCHAR (64),
@author_lname_arg VARCHAR (64)
AS
BEGIN
INSERT INTO Book(Book_id, author_id,genre_id, title, copyright)
VALUES (@author_arg, @author_id_arg, @type_id_arg, @title_arg, @copyright_arg);
INSERT INTO Author(author_id, author_fname, author_lname)
VALUES (@director_id_2_arg, @director_fname_arg, @director_lname_arg)
END;
EXECUTE Book_Book_Creation 32,32,1,'Tempting',2013,32,'Taylor','Mendez';