0

I have a simple stored procedure which inserts records into four character fields in table. Below is the procedure

CREATE PROCEDURE dowhile()

BEGIN

DECLARE I INT DEFAULT 5

v1loop: WHILE I < 10000 DO

   INSERT INTO TestTable1(A,B,C,D)

   SELECT CONCAT(I,'A'), CONCAT(I,'B'), CONCAT(I,'C'), CONCAT(I,'D')

   SET I = I + 1

END WHILE v1loop

END;

Checked online - there are no free MSSQL to MYSQL SQL Conversion Tools

Error is - SQL Syntax Error in Insert - SELECT Statement

I have checked the syntax this seem to be correct.

Any pointers for this would be helpful.

1 Answer 1

2

Not to bad actually, you just need to add some semi-colons and change MySQL's default delimiter. This needs to be done since we're using SQL inside SQL.

DELIMITER $$

CREATE PROCEDURE dowhile()

BEGIN

DECLARE I INT DEFAULT 5;

v1loop: WHILE I < 10000 DO

   INSERT INTO TestTable1(A,B,C,D)

   SELECT CONCAT(I,'A'), CONCAT(I,'B'), CONCAT(I,'C'), CONCAT(I,'D');

   SET I = I + 1;

END WHILE v1loop;

END$$

DELIMITER ;

Just tested this on my MySQL server.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.