-
Nov 17th, 2020, 04:57 PM
#1
MySQL Syntax Error Setting up SPROC
I've been using SQL server for quite some time, so I'm having a difficult time switching back to MySQL.
I have the following schema definition for my User table:
Code:
CREATE TABLE User (
UserId INT NOT NULL AUTO_INCREMENT,
AccessFailedCount INT NOT NULL DEFAULT 0,
Email VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
EmailConfirmed BIT NOT NULL DEFAULT 0,
LockoutEnabled BIT NOT NULL DEFAULT 0,
LockoutEnd DATETIME,
PasswordHash VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
PasswordSalt VARCHAR(8) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
UNIQUE KEY Index_UserId_Unique (UserId) USING BTREE,
PRIMARY KEY (UserId)
) ENGINE=InnoDB;
I'm wanting to create a stored procedure that will automatically generate a salt and as well as hash the incoming password, so I've tried to setup the following:
Code:
DELIMITER $$
CREATE PROCEDURE sproc_create_user (
IN paramEmail VARCHAR(64),
IN paramPassword VARCHAR(64)
)
BEGIN
SELECT LEFT(SHA(RAND()), 8) INTO @passwordSalt;
SELECT SHA(CONCAT(@passwordSalt, paramPassword)) INTO @passwordHash;
INSERT INTO User (
Email,
PasswordHash,
PasswordSalt
) VALUES (
paramEmail,
@passwordHash,
@passwordSalt
);
END $$
DELIMITER ;
However, I get the generic error:
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 'DELIMITER $$
CREATE PROCEDURE sproc_create_user (
IN paramEmail VARCHAR(64),
' at line 1
And I'm having a difficult time debugging what is causing it. I'm hoping an extra pair of eyes here will help.
-
Nov 18th, 2020, 02:24 AM
#2
Re: MySQL Syntax Error Setting up SPROC
Have you tried increasing the VARCHAR-size in the Parameter?
https://stackoverflow.com/questions/...ple-parameters
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
Nov 18th, 2020, 09:06 AM
#3
Re: MySQL Syntax Error Setting up SPROC
The SQL exception wasn't coming from running the SPROC, but rather from when I try to build the schema.
-
Nov 18th, 2020, 09:18 AM
#4
Re: MySQL Syntax Error Setting up SPROC
Huh?
You lost me there.....
btw: I just noticed the name of your table.
"user" is already a table in the database "mysql" (System-DB).
Have you tried qualifying the tablename/SP?
CREATE TABLE myCustomer.User....
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
Nov 18th, 2020, 09:21 AM
#5
Re: MySQL Syntax Error Setting up SPROC
Yeah, I'm not seeing it either... the only thing I can think of is maybe the version of MySQL doesn't support it? Seems like a stretch though... then again this is 2020, stranger things have happened.
-tg
-
Nov 18th, 2020, 09:37 AM
#6
Re: MySQL Syntax Error Setting up SPROC
Maybe this is just a fiddle thing and wouldn't happen in production?
Attachment 179313
Edit - Since the VBForum update, I have had very little success uploading images. If y'all can't see that image please let me know and I'll find another way to upload it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|