程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> mysql- 錯誤代碼: 1064 You have an error in your SQL syntax;

mysql- 錯誤代碼: 1064 You have an error in your SQL syntax;

編輯:編程綜合問答
錯誤代碼: 1064 You have an error in your SQL syntax;

求高手指點 語法哪裡有問題啊

DELIMITER $$

CREATE
/*[DEFINER = { user | CURRENT_USER }]*/
PROCEDURE x_similarity.CovarianceEngine()
/*LANGUAGE SQL
| [NOT] DETERMINISTIC
| { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }
| SQL SECURITY { DEFINER | INVOKER }
| COMMENT 'string'*/
BEGIN
/* 定義變量一 /
DECLARE done, done2 INT DEFAULT 0;
DECLARE stockNo_a VARCHAR(6);
DECLARE coefficient DOUBLE(16,14);
/
定義光標 */

DECLARE _Cur CURSOR FOR

SELECT DISTINCT stock_no FROM history_day;

DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;#錯誤定義,標記循環結束  

/* 打開光標 */  
OPEN _Cur;  
     /* 循環執行 */  
    REPEAT  
        FETCH _Cur INTO stockNo_a;  
        IF NOT done THEN  
            BEGIN
                /* 定義變量一 */  
                DECLARE stockNo_b VARCHAR(6);
                /* 定義光標 */ 
                DECLARE _CurInner CURSOR FOR  
                    SELECT DISTINCT stock_no FROM history_day;
                OPEN _CurInner;
                    REPEAT
                    FETCH _CurInner INTO stockNo_b;
                      IF NOT done2 THEN

                        SELECT
                            (
                                AVG(a. CLOSE * b. CLOSE) - AVG(a. CLOSE) * AVG(b. CLOSE)
                            ) / SQRT(
                                (
                                    AVG(a. CLOSE * a. CLOSE) - AVG(a. CLOSE) * AVG(a. CLOSE)
                                ) * (
                                    AVG(b. CLOSE * b. CLOSE) - AVG(b. CLOSE) * AVG(b. CLOSE)
                                )
                            ) INTO coefficient
                        FROM
                            history_day a,
                            history_day b
                        WHERE
                            a.date = b.date
                        AND a.date >= '2015-08-05'
                        AND a.date <= '2015-08-11'
                        AND a.stock_no = stockNo_a
                        AND b.stock_no = stockNo_b;

                        IF coefficient > 0.5 OR coefficient < -0.5 THEN

                            INSERT INTO correlationanalysis (stock_no_f, stock_no_r, coefficient) VALUES(stockNo_a, stockNo_b, coefficient);
                            COMMIT;

                        END IF;

                      END IF;
                    UNTIL done2 END REPEAT;
                    CLOSE _CurInner;
                SET done2 = 0;
            END
        END IF;
    UNTIL done END REPEAT;
CLOSE _Cur;
END$$

DELIMITER ;

錯誤代碼: 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 'END IF;
UNTIL done END REPEAT;
CLOSE _Cur;
END' at line 65

最佳回答:


http://zhidao.baidu.com/link?url=mljg1Vs83lzD9OIM_VcVnvefnkm5VkwVv-m46WPm5bRYag0K8xA08ltZiO8nsDL-u9Vs08dXplomY_zWXJR8V6CO7zLrY1F8mfYMj5yW8qG

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved