高手请看下timesten的 query.printColumn 报错问题
#include <ttclasses/TTStatus.h>
#include <ttclasses/TTCmd.h>
#include <ttclasses/TTConnection.h>
#include <iostream>
#include <fstream>
using namespace std;
char outputNULLStr [32] = {"NULL"} ;
char outputColumnSeparatorStr [32] = {"|"} ;
const char * connStr="DSN=TEMPTT";
const char * input_queryStr="select * from tmp";
ostream * Output = &cout ;
#define OUTPUT (*Output)
int main (int argc,char ** argv)
{
// Prepare the statement
TTConnection conn ;
TTStatus stat, stat2 ;
try {
conn.Connect(connStr, stat);
}
catch (TTWarning st) {
cout << "Warning connecting to TimesTen:" << endl << st << endl ;
}
catch (TTError st) {
cout << "Error connecting to TimesTen:" << endl << st << endl ;
if (st.rc != SQL_SUCCESS_WITH_INFO)
exit(-1);
}
TTCmd query ;
try {
query.Prepare (&conn, input_queryStr, stat) ;
}
catch (TTStatus st) {
cout << "bulkcp - query preparation failed:" << endl << st << endl ;
conn.Rollback(stat2);
conn.Disconnect(stat2);
exit(-1);
}
try {
query.Execute (stat) ;
}
catch (TTStatus st) {
cout << "bulkcp - query execution failed:" << endl << st << endl ;
conn.Rollback(stat2);
conn.Disconnect(stat2);
exit(-1);
}
int num_result_cols = query.getNColumns() ;
try { // fetch loop
while ( !query.FetchNext(stat) ) // loop until no rows found, or a signal caught
{
// fetch a row; if no more rows, break out of loop
// FetchNext returns 0 for success, 1 for SQL_NO_DATA_FOUND
// for each row fetched, print out its column values
for ( int i = 1 ; i <= num_result_cols ; i++ )
{
query.printColumn (i, OUTPUT, outputNULLStr) ;
if ( i < num_result_cols )
OUTPUT << outputColumnSeparatorStr ;
}
OUTPUT << endl ;
}
} // end of fetch loop
catch (TTStatus st) {
cout << "bulkcp -- error while fetching rows:" << endl << st << endl ;
conn.Rollback(stat2);
conn.Disconnect(stat2);
exit(-1);
}
// No need to clean up here when we catch a signal, since the following
// code does the required cleanup.
// time to clean up
try {
query.Close(stat) ;
query.Drop(stat) ;
conn.Commit(stat) ;
conn.Disconnect(stat);
}
catch (TTStatus st) {
cout << "Error cleaning up:" << endl << st << endl ;
conn.Rollback(stat2);
conn.Disconnect(stat2);
exit(-1);
}
return 0 ;
}
代码如上:
每次执行到 query.printColumn (i, OUTPUT, outputNULLStr) ;时,程序就异常退出了
First-chance exception in test11.exe (NTDLL.DLL): 0xC0000005: Access Violation.
请各位高手帮忙分析一下原因,非常感谢!
高手请看下timesten的 query.printColumn 报错问题
字体: 小 中 大 | 打印 发表于: 2008-8-20 12:50 作者: zouxiaodong 来源: CNOUG博客首页
查看全部回复
我也来说两句
