Question
This is in MySQL Server. Using the My Guitar Shop database you installed in Module 1, develop the following queries. Write a script that creates
This is in MySQL Server.
Using the My Guitar Shop database you installed in Module 1, develop the following queries. Write a script that creates and calls a stored procedure named insert_category. First, code a statement that creates a procedure that adds a new row to the Categories table. To do that, this procedure should have one parameter for the category name. Code at least two CALL statements that test this procedure. (Note that this table doesnt allow duplicate category names.) Execute the query and take a screenshot of the query and the results.
I currently have this as my code:
DROP PROCEDURE IF EXISTS insert_category; DELIMITER // CREATE PROCEDURE insert_category ( var_category_id INT, var_category_name varchar(50) ) BEGIN DECLARE sql_error TINYINT DEFAULT FALSE; DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET sql_error = TRUE; START TRANSACTION; UPDATE categories SET category_id = var_category_id WHERE category_name = var_category_name; IF sql_error = FALSE THEN COMMIT; ELSE ROLLBACK; END IF; END// DELIMITER ; -- Test fail: call insert_category (3,'Basses'); -- Test pass: call insert_category (4,'Piano');
I am getting this error though. "Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 5." Line 5 is var_category_id INT, What am I doing wrong?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started