0
我想創建一個4插入一個存儲過程,我有這樣的代碼MySQL連接/ C++聲明變量
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");
whay我得到這個錯誤# 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)