ocitest.cpp

来自「调用OCI的C++类」· C++ 代码 · 共 65 行

CPP
65
字号
#include <iostream>#include <cstring>#include <ctime>using namespace std;#include "TOCIQuery.h"int main(){	cout << "ocitest start..." << endl;		try 	{		TOCIDatabase database;		TOCIQuery * qry;				database.connect("BILL","BILL","");				cout << "connect database success" << endl;		//system("date");		time_t stime;		time(&stime);			qry = new TOCIQuery(&database);		                char *scripSelect= "SELECT 1234567890 ID FROM DUAL";		                qry->setSQL(scripSelect);		qry->open();                qry->next();                    cout << "ID-Float:   " << qry->field("ID").asFloat()   << endl;                cout << "ID-Integer: " << qry->field("ID").asInteger() << endl;                cout << "ID-String:  " << qry->field("ID").asString()  << endl;                delete qry;		time_t etime;		time(&etime);		int utime;		utime = etime-stime;        }	catch(TOCIException &oe)	{		cout<<"TOCIException catched"<<endl;		cout<<oe.getErrMsg()<<endl;				cout<<oe.getErrSrc()<<endl;	}	catch(...)	{		cout<<"Exception occur"<<endl;	}	// system("date");		return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?