0

4挿入でストアドプロシージャを作成したいのですが、このコードがあります

  Driver * driver = get_driver_instance();
  auto_ptr< Connection > vCon(driver->connect(getHost(), getUser(), getPassword()));
  vCon->setSchema(getDB());
  auto_ptr< Statement > vStmt(vCon->createStatement());

  vStmt->execute("DROP PROCEDURE IF EXISTS add");
  vStmt->execute("CREATE PROCEDURE add() begin DECLARE vEvId int DEFAULT 0; DECLARE vAdrEvId int DEFAULT 0; insert into adrEv(den) values('test'); select last_insert_id() into vAdrEvId; insert into ev(den,adrEvId) values('test',vAdrEvId);  select last_insert_id() into vEvId;  ... other insert ...   END;");

  vStmt->execute("CALL add()");
  vStmt->execute("DROP PROCEDURE IF EXISTS add");

このエラーが発生する理由# ERR: 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 'add' at line 1 (MySQL error code: 1064, SQLState: 42000 )

4

1 に答える 1

1

ADDMySQLの予約語です。より具体的/説明的なプロシージャ名を使用してみてください。

于 2012-05-12T10:10:43.957 に答える