日期:2014-05-17 浏览次数:20830 次
#include <string> #include <iostream> #include <occi.h> #pragma comment (lib, "oraocci11d.lib") using namespace std; int SelectFrom (char *sqlexec); int main () { char a[] = {"SELECT * FROM AAVARX"}; int b = SelectFrom (a); cout<<a<<endl; system ("pause"); return 0; } int SelectFrom (char *sqlexec) { oracle::occi::Environment *env = oracle::occi::Environment::createEnvironment (); oracle::occi::Connection *coon = env ->createConnection ("boss", "zzs880905", "shop"); oracle::occi::Statement *stmt = coon ->createStatement (sqlexec); oracle::occi::ResultSet *res = stmt ->executeQuery (); res ->next (); sqlexec = (char *)malloc (strlen (res ->getString (1).c_str ())); char *temp = strcpy (sqlexec, res ->getString (1).c_str ()); temp = strcat (sqlexec, res ->getString (2).c_str ()); coon ->terminateStatement (stmt); env ->terminateConnection (coon); oracle::occi::Environment::terminateEnvironment (env); cout<<sqlexec<<endl; return 0; }