以下Java代码(使用Connector / J在MySQL 5.0上创建存储过程)无法成功执行。
statement.execute("DELIMITER //\nCREATE PROCEDURE abdt (std INT)\nBEGIN\nSELECT att_begin, att_end FROM abdt WHERE student_id = std;\n\nEND;\n//\nDELIMITER ;");
请你试着解释一下为什么这样有效?
String query="";
query = "CREATE PROCEDURE process_something (IN input_id BIGINT)\n";
query+= "BEGIN\n";
query+= "DECLARE num_rows, cnt, last_id INT DEFAULT 0;\n";
query+= "DECLARE indx_found INT DEFAULT 0;\n";
query+= _mainStoreProcedureBody;
query+= "END\n";
Connection con= session.connection();
Statement st= con.createStatement();
st.executeUpdate(query);
非常感谢任何可能的帮助。 谢谢