我想用 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 )