Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1

    Unanswered: MySQL multi-statement and variable syntax.

    Running this through my SQL utility yields an error
    Code:
        DECLARE xname VARCHAR(5) DEFAULT 'bob';
        DECLARE newname VARCHAR(5);
        DECLARE xid INT;
    " You have an error in your SQL syntax; chekc the manual that corresponds to your MySQL server version for the right syntax to use"
    ...but I got the syntax from this example in the manual:
    Code:
    CREATE PROCEDURE sp1 (x VARCHAR(5))
      BEGIN
        DECLARE xname VARCHAR(5) DEFAULT 'bob';
        DECLARE newname VARCHAR(5);
        DECLARE xid INT;
        
        SELECT xname,id INTO newname,xid 
          FROM table1 WHERE xname = xname;
        SELECT newname;
      END;
    So my question is, can variables not be defined in scripts, or do I need a different syntax for multi-statement operations?
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Am I to take it that this can't be done using MySQL scripts?
    If not, do I need to develop my script as a stored procedure in order to test it?
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •