MySQL Forums
Forum List  »  Newbie

How to declare and use user variables in script (SQL1.sql)
Posted by: George Padvorac
Date: May 03, 2022 09:47AM

I come from the SQL Server world and am finding many things difficult to do in MySQL. For example:

I have a script used for testing various operations and it doesn't like me to declare variables, but the exact same code works inside a stored procedure.

For example:

DECLARE newguid VARCHAR(36);
SET newguid = NULL;

I get a red squiggly under the declare statement and this error when I try to execute it:

1 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 'DECLARE newguid VARCHAR(36)' at line 1 SQL1.sql 4 1


I tried using this syntax also:

DECLARE @newguid VARCHAR(36);

With the same result. Are we only allowed to declare variables inside stored procedures?

Thank you.

Options: ReplyQuote


Subject
Written By
Posted
How to declare and use user variables in script (SQL1.sql)
May 03, 2022 09:47AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.