我无法看到这种语法有什么问题请帮忙!我试着从这里查找语法 http://dev.mysql.com/doc/refman/5.5/en/declare-handler.html
DELIMITER $$
DROP PROCEDURE IF EXISTS `load_dimensions`$$
CREATE PROCEDURE `load_dimensions`( )
BEGIN
-- Declare variables to hold diagnostics area information
DECLARE code CHAR(5) DEFAULT '00000';
DECLARE msg TEXT;
DECLARE rows INT;
DECLARE result varchar(300);
-- Declare exception handler for failed insert
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
BEGIN
GET DIAGNOSTICS CONDITION 1 code = RETURNED_SQLSTATE, msg = MESSAGE_TEXT;
END;
INSERT dimtable(col)
SELECT col FROM extract;
IF code = '00000' THEN
GET DIAGNOSTICS rows = ROW_COUNT;
SET result = CONCAT('succeeded, row count = ',rows);
INSERT INTO etl_log (result)
SELECT CONCAT('Error',state,': ',msg);
ELSE
SET result = CONCAT('failed, error = ',code,', message = ',msg);
INSERT INTO etl_log (result)
SELECT CONCAT('Error',state,': ',msg);
END IF;
END $$