0

I want to create a stored procedure with 4 insert and i have this code

  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 i get this error # 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 )

1 Answer 1

1

ADD is a reserved word for MySQL. Try using a more specific/descriptive procedure name.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.