MySql中的警告1072 - 表格中不存在密钥列“名称”

时间:2011-09-21 11:31:51

标签: mysql sql warnings

获取警告0 row(s) affected, 1 warning(s): 1072 Key column 'name' doesn't exist in table我不知道这意味着什么。有人有解释吗?

表/ SP如下

CREATE TABLE IF NOT EXISTS `sectors`
(
  `id`        INT(10) UNSIGNED   NOT NULL AUTO_INCREMENT ,
  `sector`    VARCHAR(25)        NOT NULL ,
                                                                           --
  PRIMARY KEY (`id`) ,
  UNIQUE  INDEX `sector_idx` USING BTREE (`sector` ASC)
);
DELIMITER $$
CREATE PROCEDURE `AddSector` (IN sector VARCHAR(25),
                              OUT result BOOLEAN)
  MODIFIES SQL DATA
BEGIN
  DECLARE CONTINUE HANDLER FOR SQLWARNING, SQLEXCEPTION SET result = FALSE;
  SET result = TRUE;
                                                                           --
  INSERT INTO `sectors` (`sector`) VALUES (sector);
  COMMIT;
END $$

1 个答案:

答案 0 :(得分:0)

将程序更改为:

DELIMITER $$

CREATE PROCEDURE `AddSector` (IN pSector VARCHAR(25),  <<-- fix nameclash here
                              OUT result BOOLEAN)
  MODIFIES SQL DATA
BEGIN
  DECLARE CONTINUE HANDLER FOR SQLWARNING, SQLEXCEPTION SET result = FALSE;
  SET result = TRUE;

  INSERT INTO `sectors` (`sector`) VALUES (pSector);  <<-- and here
  --  COMMIT;  <<-- You don't need a commit.
END $$

存储过程中的所有内容都已经在隐式事务中运行,因此不需要提交,实际上可能是错误(不确定)。     DELIMITER;