Home > database >  Refer to the mysql cursor loop inserts
Refer to the mysql cursor loop inserts

Time:10-08

The code below
Every time an error is wrong grammar I checked several times also can not find error
1064 - 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 'SELECT ` ` issues, ` title `, ` ` publication period, the SUM (` `), ` ` book publication unit, ` ` channels FROM ` _20' at line 11
Time: 0 s



Delimiter $
CREATE PROCEDURE ` cursor loop insert ` ()
The BEGIN
DECLARE b VARCHAR (20);
DECLARE c VARCHAR (80);
DECLARE d VARCHAR (20);
DECLARE e int.
DECLARE f VARCHAR (80);
DECLARE g VARCHAR (20);
DECLARE h int.
DECLARE a int the DEFAULT 0;
DECLARE cur1 CURSOR FOR the SELECT ` ` issues, ` title `, ` ` publication period, the SUM (` `), ` ` book publication unit, ` ` channels FROM ` _20 official version in order ` GROUP BY ` ` issues, ` title `, ` publication period `, ` ` book publication unit, ` ` channel;
DECLARE the CONTINUE HANDLER FOR the NOT found SET a=1;
The OPEN cur1
REPEAT
The FETCH cur1 INTO b, c, d, e, f, g;
IF d=` monthly ` THEN
REPEAT
The SET h=1
INSERT INTO ` 20 years went library ` (` ` issues, ` title `, ` nper `, ` quantity ` ` ` channel, ` subscriber `) VALUES (b, c, h, e, f, g)
The SET h=h + 1
REPEAT UNTIL h=12 END;


The ELSE
REPEAT
The SET h=1
INSERT INTO ` 20 years went library ` (` ` issues, ` title `, ` nper `, ` quantity ` ` ` channel, ` subscriber `) VALUES (b, c, h, e, f, g)
The SET h=h + 1
REPEAT UNTIL h=24 END;

END the IF;
REPEAT UNTIL a=1 END;




The CLOSE cur1



END $
Call ` cursor loop insert ` ()

CodePudding user response:

SELECT ` ` issues, ` title `, ` ` publication period, the SUM (` `), ` ` book publication unit, ` ` channels FROM ` _20 official version in order ` GROUP BY ` ` issues, ` title `, ` publication period `, ` ` book publication unit, ` ` channel; Alone can run

CodePudding user response:

Can

CodePudding user response:

The SUM (` `) to SUM (` `) as the number of try

CodePudding user response:

reference 3 floor is just a reply:
SUM (` `) to SUM (` `) as the number of try
ok thank you
  • Related