OTL执行SQL语句的两种方式
1、使用otl_cursor::direct_exec(...)函数直接执行sql语句
例如otl_cursor::direct_exec(db,"create table ccc(aa int);");
2、使用otl_stream流执行sql语句使用步骤如下
otl_stream otlCur(1,(const char*)str,db);
//或者
otl_stream otlCur;
otlCur.open(1,(const char*)str,db);//有点像fstream使用方式
2.1使用otl_stream流查询表以后把数据取出来的例子如下
int OTLSelete(otl_connect &db)
{
try{
// const char * str = "select aa from ccc where aa < 7 order by aa asc;";
// const char * str = "select * from ccc;";
const char * str = "select aa as ddd from ccc where aa < 7 ";
otl_stream otlCur(1,(const char*)str,db);
cout << " select result begin"<<endl;
otl_column_desc* desc = NULL;
int nlistlen = 1;
desc=otlCur.describe_select(nlistlen); //取字段
cout<<desc->name<<endl;
while(!otlCur.eof())
{
int aa =0;
// char *p=NULL;//error
char p[64];
otlCur>>aa;
// otlCur>>p;
cout <<" aa ="<< aa <<endl;
// cout <<" bb ="<< p <<endl;
}
cout << " select result end"<<endl;
}
有一篇不错的用法 https://blog.csdn.net/nie2314550441/article/details/49454311
C++交流群:585225803