Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

***SQL HELP PLEASE***I am having trouble with my sql script. My professor wants a save point and rollback in our stored procedure, i keep getting

***SQL HELP PLEASE***I am having trouble with my sql script. My professor wants a save point and rollback in our stored procedure, i keep getting an error when i create the save point, when i have just the rollback everything runs fine, here is my script with the savepoint and i will insert a picture of the error too.

DROP DATABASE IF EXISTS `database soccer`; -- Database Creation Script -- MySQL Workbench Forward Engineering SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'; -- ----------------------------------------------------- -- Schema database soccer -- ----------------------------------------------------- -- ----------------------------------------------------- -- Schema database soccer -- ----------------------------------------------------- CREATE SCHEMA IF NOT EXISTS `database soccer` DEFAULT CHARACTER SET utf8 ; USE `database soccer` ; -- ----------------------------------------------------- -- Table `database soccer`.`country` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `database soccer`.`country` ( `Country_ID` INT NOT NULL, `Country_name` VARCHAR(45) NOT NULL, PRIMARY KEY (`Country_ID`)) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8; -- ----------------------------------------------------- -- Table `database soccer`.`team` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `database soccer`.`team` ( `Team_ID` INT NOT NULL, `team_name` VARCHAR(45) NOT NULL, `Team_Stats` VARCHAR(45) NOT NULL, `Country_Country_ID` INT NOT NULL, PRIMARY KEY (`Team_ID`), INDEX `fk_Team_Country_idx` (`Country_Country_ID` ASC) VISIBLE, CONSTRAINT `fk_Team_Country` FOREIGN KEY (`Country_Country_ID`) REFERENCES `database soccer`.`country` (`Country_ID`)) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8; -- ----------------------------------------------------- -- Table `database soccer`.`game` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `database soccer`.`game` ( `Game_ID` INT NOT NULL, `Game_Score` VARCHAR(45) NULL DEFAULT NULL, `Team_Team_ID` INT NOT NULL, PRIMARY KEY (`Game_ID`), INDEX `fk_Game_Team1_idx` (`Team_Team_ID` ASC) VISIBLE, CONSTRAINT `fk_Game_Team1` FOREIGN KEY (`Team_Team_ID`) REFERENCES `database soccer`.`team` (`Team_ID`)) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8; -- ----------------------------------------------------- -- Table `database soccer`.`player` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `database soccer`.`player` ( `Player_ID` INT NOT NULL, `Player_Name` VARCHAR(45) NOT NULL, `Team_Team_ID` INT NOT NULL, `DateOfBirth` DATE NULL DEFAULT NULL, PRIMARY KEY (`Player_ID`), INDEX `fk_Player_Team1_idx` (`Team_Team_ID` ASC) VISIBLE, CONSTRAINT `fk_Player_Team1` FOREIGN KEY (`Team_Team_ID`) REFERENCES `database soccer`.`team` (`Team_ID`)) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8; -- ----------------------------------------------------- -- Table `database soccer`.`player_has_game` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `database soccer`.`player_has_game` ( `Player_Player_ID` INT NOT NULL, `Game_Game_ID` INT NOT NULL, PRIMARY KEY (`Player_Player_ID`, `Game_Game_ID`), INDEX `fk_Player_has_Game_Game1_idx` (`Game_Game_ID` ASC) VISIBLE, INDEX `fk_Player_has_Game_Player1_idx` (`Player_Player_ID` ASC) VISIBLE, CONSTRAINT `fk_Player_has_Game_Game1` FOREIGN KEY (`Game_Game_ID`) REFERENCES `database soccer`.`game` (`Game_ID`), CONSTRAINT `fk_Player_has_Game_Player1` FOREIGN KEY (`Player_Player_ID`) REFERENCES `database soccer`.`player` (`Player_ID`)) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8; SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; -- Insert Data Script INSERT INTO country (Country_ID, Country_name) VALUES (1, 'Mexico'), (2, 'US'), (3, 'China'), (4, 'France'); INSERT INTO team (Team_ID, team_name, Team_Stats, Country_Country_ID) VALUES (1, 'Mexico', 88, 1), (2, 'US', 78, 2), (3, 'China', 84, 3), (4, 'France', 92, 4); -- Player INSERT INTO player (Player_ID, Player_Name, Team_Team_ID, DateOfBirth) VALUES (1, 'Daniel Martel', 1, '1990-01-01'), (2, 'Cuarto Balasco', 1, '1991-02-05'), (3, 'Salvador Paz', 1, '1989-04-15'), (4, 'Elia Bojorquez', 1, '1992-08-20'), (5, 'Juliano Esquilin', 1, '1988-11-12'), (6, 'Ambrosio Coito', 1, '1994-03-25'), (7, 'Rico Farin', 1, '1993-06-30'), (8, 'Roldan Callejo', 1, '1990-09-10'), (9, 'Segundo Lince', 1, '1987-12-18'), (10, 'Victoro Paramo', 1, '1995-02-28'), (11, 'Natal Torralba', 1, '1991-05-14'), (12, 'Jax San Antonio', 1, '1989-08-28'), (13, 'Jonah Bates', 2, '1993-12-02'), (14, 'Titus Cooper', 2, '1992-04-17'), (15, 'Orion Brown', 2, '1990-09-05'), (16, 'Otto Howard', 2, '1991-07-22'), (17, 'Damian Patterson', 2, '1988-03-11'), (18, 'Josiah Baker', 2, '1995-06-26'), (19, 'Joshua Gilbert', 2, '1994-10-12'), (20, 'Tristan Watson', 2, '1992-01-31'), (21, 'Roman Rogers', 2, '1989-08-14'), (22, 'Nathan Hughes', 2, '1990-12-28'), (23, 'Evan Parson', 2, '1993-02-15'), (24, 'Andre Ruiz', 2, '1995-04-07'), (25, 'Tan Zhong', 3, '1991-09-19'), (26, 'Shen Xiang', 3, '1988-05-03'), (27, 'Wan Tengfei', 3, '1994-01-18'), (28, 'Zhao Nianzu', 3, '1992-06-10'), (29, 'Dai Qing', 3, '1996-11-24'), (30, 'Liu Liwei', 3, '1997-03-09'), (31, 'Hao Junjie', 3, '1990-08-14'), (32, 'Peng Liu', 3, '1989-12-28'), (33, 'Tian Tian', 3, '1991-02-15'), (34, 'Yu Xin', 3, '1995-04-07'), (35, 'Cao Ai', 3, '1988-09-19'), (36, 'Lei Shun', 3, '1992-05-03'), (37, 'Lonie Renaud', 4, '1996-01-18'), (38, 'Nicolas Pierre', 4, '1993-06-10'), (39, 'Guillaume Gagnon', 4, '1997-11-24'), (40, 'Jose Paquet', 4, '1998-03-09'), (41, 'Eugnie Andr', 4, '1994-07-23'), (42, 'Mauger Dupont', 4, '1995-11-06'), (43, 'Raulf Sault', 4, '1992-04-20'), (44, 'Godefrey Jacques', 4, '1996-08-03'), (45, 'Rmy Lambert', 4, '1993-01-16'), (46, 'Lazare Desrosiers', 4, '1991-06-28'), (47, 'Bastien Gosse', 4, '1994-10-11'), (48, 'Rodrigue Merle', 4, '1998-02-24'); -- Game INSERT INTO game (Game_ID, Game_Score, Team_Team_ID) VALUES (1, 26, 1), (2, 30, 4), (3, 32, 1), (4, 28, 4), (5, 28, 3), (6, 34, 4); -- Player_has_Game INSERT INTO player_has_game (Player_Player_ID, Game_Game_ID) VALUES (1, 1), (2, 1), (3, 1), (4, 1), (5, 1), (6, 1), (7, 1), (8, 1), (9, 1), (10, 1), (11, 1), (12, 1), (13, 1), (14, 1), (15, 1), (16, 1), (17, 1), (18, 1), (19, 1), (20, 1), (21, 1), (22, 1), (23, 1), (24, 1), (25, 2), (26, 2), (27, 2), (28, 2), (29, 2), (30, 2), (31, 2), (32, 2), (33, 2), (34, 2), (35, 2), (36, 2), (37, 2), (38, 2), (39, 2), (40, 2), (41, 2), (42, 2), (43, 2), (44, 2), (45, 2), (46, 2), (47, 2), (48, 2), (1, 3), (2, 3), (3, 3), (4, 3), (5, 3), (6, 3), (7, 3), (8, 3), (9, 3), (10, 3), (11, 3), (12, 3), (25, 3), (26, 3), (27, 3), (28, 3), (29, 3), (30, 3), (31, 3), (32, 3), (33, 3), (34, 3), (35, 3), (36, 3), (13, 4), (14, 4), (15, 4), (16, 4), (17, 4), (18, 4), (19, 4), (20, 4), (21, 4), (22, 4), (23, 4), (24, 4), (37, 4), (38, 4), (39, 4), (40, 4), (41, 4), (42, 4), (43, 4), (44, 4), (45, 4), (46, 4), (47, 4), (48, 4), (13, 5), (14, 5), (15, 5), (16, 5), (17, 5), (18, 5), (19, 5), (20, 5), (21, 5), (22, 5), (23, 5), (24, 5), (25, 5), (26, 5), (27, 5), (28, 5), (29, 5), (30, 5), (31, 5), (32, 5), (33, 5), (34, 5), (35, 5), (36, 5), (1, 6), (2, 6), (3, 6), (4, 6), (5, 6), (6, 6), (7, 6), (8, 6), (9, 6), (10, 6), (11, 6), (12, 6), (37, 6), (38, 6), (39, 6), (40, 6), (41, 6), (42, 6), (43, 6), (44, 6), (45, 6), (46, 6), (47, 6), (48, 6); -- Simple Query Scripts SELECT * FROM country; SELECT * FROM team; SELECT * FROM player; SELECT * FROM game; SELECT * FROM player_has_game; -- Arithmetic Calculation Script SELECT Player_Name, YEAR(CURDATE()) - YEAR(DateOfBirth) - (RIGHT(CURDATE(), 5) 25; image text in transcribed

Automatic context help is disabled. Use the toolbar to manually get help for the current caret position or to toggle automatic help

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Performance Indexing In SQL Server

Authors: Jason Strate, Grant Fritchey

2nd Edition

1484211189, 9781484211182

More Books

Students also viewed these Databases questions

Question

=+a) Compute the EV for each alternative product (decision).

Answered: 1 week ago