Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MySQL Workbench (Error Code: 1327. Undeclared variable: order_id) Just need to know why I am encountering this error in the following code; DROP PROCEDURE IF

MySQL Workbench (Error Code: 1327. Undeclared variable: order_id)

Just need to know why I am encountering this error in the following code;

DROP PROCEDURE IF EXISTS test; DELIMITER //

CREATE PROCEDURE test() BEGIN DECLARE sql_error TINYINT DEFAULT FALSE;

DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET sql_error = TRUE;

START TRANSACTION;

INSERT INTO orders VALUES (DEFAULT, 3, NOW(), '10.00', '0.00', NULL, 4, 'American Express', '378282246310005', '04/2016', 4);

SELECT LAST_INSERT_ID() INTO order_id;

INSERT INTO order_items VALUES (DEFAULT, order_id, 6, '415.00', '161.85', 1);

INSERT INTO order_items VALUES (DEFAULT, order_id, 1, '699.00', '209.70', 1);

IF sql_error = FALSE THEN COMMIT; SELECT 'The transaction was committed.';

END IF; END // DELIMITER ; call test();

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

4. Name and describe the main internal sources of candidates.

Answered: 1 week ago