Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADS return error and the same statement works in mysql workbench #243

Open
crushonme opened this issue Jul 22, 2024 · 0 comments
Open

ADS return error and the same statement works in mysql workbench #243

crushonme opened this issue Jul 22, 2024 · 0 comments

Comments

@crushonme
Copy link

I tried to generate a sample data in MySQL database with below command. In ADS, it always return error "1064 (42000): 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 InsertRandomCustomers(IN num_records INT)
BEGIN
' at line 1".
However the same statement works normal in MySQL workbench. Please help to fix it.

USE tutorialdb;
SET @names = 'Orlando,Keith,Donna,Janet,Alice,Bob,Carol,David,Emma,Frank,Grace,Henry,Ivy,Jack,Kate,Liam,Mia,Nathan,Olivia,Peter,Quinn,Rachel,Simon,Tina,Victor,Wendy,Xavier,Yvonne,Zach';
SET @countries = 'China,United States,Russia,India,Brazil,South Africa,Mexico,Australia,Japan,Germany';
DELIMITER $$
CREATE PROCEDURE InsertRandomCustomersaa(IN num_records INT)
BEGIN
   DECLARE i INT DEFAULT 1895;
   DECLARE random_name VARCHAR(255);
   DECLARE random_location VARCHAR(255);
   WHILE i < num_records DO
       SET random_name = SUBSTRING_INDEX(SUBSTRING_INDEX(@names, ',', FLOOR(RAND() * 26) + 1), ',', -1);
       SET random_location = SUBSTRING_INDEX(SUBSTRING_INDEX(@countries, ',', FLOOR(RAND() * 10) + 1), ',', -1);
       INSERT INTO customers (name, location, email)
       VALUES (random_name, random_location, CONCAT(random_name, '@adventure-works.com'));
       SET i = i + 1;
   END WHILE;
END$$
DELIMITER ;
CALL InsertRandomCustomersaa(10000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant