Question
I get this error running the following MYSQL script. ERROR 1064(42000) at line 1: You have an error in your SQL syntax; check them anual
I get this error running the following MYSQL script. ERROR 1064(42000) at line 1: You have an error in your SQL syntax; check them anual that corresponds to your MySQL server version for the rightsyntax to use near '' at line 3 CREATE PROCEDURE PRC_INV_AMOUNTS(IN W_IN INT) BEGIN DECLARE W_CHK INT DEFAULT 0; DECLARE W_SUBT INTDEFAULT 0; DECLARE W_TAX INT DEFAULT 0; SELECT COUNT(*) INTO W_CHKFROM INVOICE WHERE INV_NUMBER = W_IN; IF W_CHK = 1 THEN SELECTSUM(LINE_TOTAL) INTO W_SUBT FROM LINE WHERE LINE.INV_NUMBER = W_IN;SET W_TAX = W_SUBT * 0.08; UPDATE INVOICE SET INV_SUBTOTAL =W_SUBT, INV_TAX = W_TAX, INV_TOTAL = W_SUBT + W_TAX WHEREINV_NUMBER = W_IN; END IF; END; When I remove the declarestatements from the script , I get: ERROR 1327 (42000) at line 1:Undeclared variable: W_CHK. Is the syntax wrong for the declarestatements?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
You should use DELIMITER keyword to create a procedure in MySQL Use the below script DELIMITER CR...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