2
DROP PROCEDURE IF EXISTS proc_x;
DELIMITER #
CREATE DEFINER=`root`@`localhost`  PROCEDURE proc_x(sequel CHAR)
proc_main:BEGIN
SET @SQL = CONCAT(@sequel);
PREPARE stmt FROM @SQL;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END proc_main #

Above is a syntax for creating stored procedure in my mysql database. When I execute following statement I get error.

CALL proc_x("INSERT  INTO tbl_rec(id,name,brnachID) values(10,'Krunal',07)");

Error : ERROR 1064 (42000) at line 93: 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 'NULL' at line 1

Can anyone help me to solve it?

Currently I'm using Mysql on UNIX.

2
(sequel CHAR)
CONCAT(@sequel)

@variables are totally independent of non-@ variables.

Two fixes needed:

  • SET @SQL = CONCAT(@sequel); --> SET @SQL = sequel;
  • (sequel CHAR) --> (sequel VARCHAR(999))
0

Make the changes in your query as follows:

INSERT INTO table_name (`column1`, `column2`) values ('val1', 'val2');

Note that the column names are enclosed in ` (character above tab) and not in quotes

-3

Do you get error for every query or while executing this query only?

If you are facing problem executing every query,then just go to google,install XAMPP control panel and enable the MySQL button by clicking it. Then find "XAMPP->MySQL->bin" in the parted HDD where you have installed XAMPP and within XAMPP folder. Copy the path go to command prompt go to folder enter the path by "cd C:XAMPP->MySQL->bin" like this.

Actually the root@localhost is listed in XAMPP->MySQL->bin folder.

If you are facing problem with every query just uninstall MYSQL,find the latest version and install it again or update the previous one.

Hope it'll solve your problem. thanks.

  • 2
    To fix syntax errors? Really? – Colin 't Hart Mar 25 '15 at 8:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.