Results 1 to 6 of 6

Thread: MySQL Syntax Error Setting up SPROC

  1. #1

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,892

    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.

  2. #2
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    2,291

    Re: MySQL Syntax Error Setting up SPROC

    Have you tried increasing the VARCHAR-size in the Parameter?

    https://stackoverflow.com/questions/...ple-parameters
    One System to rule them all, One IDE to find them,
    One Code 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.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  3. #3

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,892

    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.

  4. #4
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    2,291

    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....
    One System to rule them all, One IDE to find them,
    One Code 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.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    33,139

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,892

    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
  •  



Click Here to Expand Forum to Full Width