MySQL Connector/C++ 调用存储过程
来源:互联网 发布:同为模拟录像机改网络 编辑:程序博客网 时间:2024/06/11 17:07
MySQL Connector/C++ 调用存储过程
(金庆的专栏)
摘自:
http://dev.mysql.com/doc/refman/5.6/en/connector-cpp-tutorials-stored-routines-statements.html
CREATE PROCEDURE test (IN country_code CHAR(3), OUT country_pop INT(11))
BEGIN
INSERT INTO Country(Code) VALUES (country_code);
SELECT Population INTO country_pop FROM Country WHERE Name = 'country_name';
SELECT Code, Name, Population, Continent FROM Country WHERE Continent = "Oceania" AND Population < 10000;
SELECT Code, Name, Population, Continent FROM Country WHERE Continent = "Europe" AND Population < 10000;
SELECT Code, Name, Population, Continent FROM Country WHERE Continent = "North America" AND Population < 10000;
END
sql::Driver* driver = get_driver_instance();
std::auto_ptr<sql::Connection> con(driver->connect(url, user, pass));
con->setSchema(database);
std::auto_ptr<sql::Statement> stmt(con->createStatement());
stmt->execute("CALL test(\"ATL\", @pop)");
std::auto_ptr< sql::ResultSet > res;
do {
res.reset(stmt->getResultSet());
while (res->next()) {
cout << "Result: " << res->getString(1) << endl;
}
} while (stmt->getMoreResults());
std::auto_ptr<sql::ResultSet> res(stmt->executeQuery("SELECT @pop AS _reply"));
while (res->next())
cout << "Population of Uganda: " << res->getString("_reply") << endl;
(金庆的专栏)
摘自:
http://dev.mysql.com/doc/refman/5.6/en/connector-cpp-tutorials-stored-routines-statements.html
CREATE PROCEDURE test (IN country_code CHAR(3), OUT country_pop INT(11))
BEGIN
INSERT INTO Country(Code) VALUES (country_code);
SELECT Population INTO country_pop FROM Country WHERE Name = 'country_name';
SELECT Code, Name, Population, Continent FROM Country WHERE Continent = "Oceania" AND Population < 10000;
SELECT Code, Name, Population, Continent FROM Country WHERE Continent = "Europe" AND Population < 10000;
SELECT Code, Name, Population, Continent FROM Country WHERE Continent = "North America" AND Population < 10000;
END
sql::Driver* driver = get_driver_instance();
std::auto_ptr<sql::Connection> con(driver->connect(url, user, pass));
con->setSchema(database);
std::auto_ptr<sql::Statement> stmt(con->createStatement());
stmt->execute("CALL test(\"ATL\", @pop)");
std::auto_ptr< sql::ResultSet > res;
do {
res.reset(stmt->getResultSet());
while (res->next()) {
cout << "Result: " << res->getString(1) << endl;
}
} while (stmt->getMoreResults());
std::auto_ptr<sql::ResultSet> res(stmt->executeQuery("SELECT @pop AS _reply"));
while (res->next())
cout << "Population of Uganda: " << res->getString("_reply") << endl;
- MySQL Connector/C++ 调用存储过程
- MySQL Connector C++ 调用存储过程
- c / c + + 调用mysql存储过程
- c / c + + 调用mysql存储过程
- c/c++调用mysql存储过程
- c/c++中调用mysql存储过程
- c/c++调用mysql存储过程
- c/c++调用mysql存储过程 收藏
- C语言调用mysql存储过程出错
- mysql C API 调用存储过程
- c/c++调用mysql存储过程
- c/c++调用mysql存储过程
- c/c++调用mysql存储过程
- c/c++调用MySql的存储过程
- C语言调用mysql的存储过程
- mysql存储过程调用
- MySQL++调用存储过程
- 调用mysql存储过程
- HDU 3605 Escape 最大流
- chrome 实用快捷方式
- C++笔试题大全----上
- lnmp 下codeigniter的配置
- CSV导出内容包含逗号
- MySQL Connector/C++ 调用存储过程
- 网络号与子网号
- 20个数据库设计最佳实践
- C++笔试题大全----下
- 青花瓷的传说
- Chap7:Jni中C++和Java的参数传递
- spagobi系列文章-03 document配置
- Oracle中的语言
- 在linux内核中操作文件的方法