我想使用以下代码在 oracle 中为 DATE 进行数组获取。它可以正常编译并正确导出所有其他数据类型,但 DATE 类型除外。该程序说“ora-32146 无法在空日期执行操作”。
任何人都可以看到我错在哪里?
Statement *stmt = conn->createStatement("SELECT AGE,CASH2, BIRTHDATE from myTable2"); /*, CASH1, CASH2, BIRTHDATE*/
//stmt->setMaxParamSize(1,sizeof(Number));
ResultSet *rs=stmt->executeQuery();
string myName[400];
int myAge[400];
double myCash1[400];
double myCash2[400];
oracle::occi::Date myBirthDate[400];
//rs->setDataBuffer(1,myName,OCCI_SQLT_STR,sizeof(string));
rs->setDataBuffer(1,myAge,OCCIINT,sizeof(int));
rs->setDataBuffer(2, myCash2, OCCIBDOUBLE, sizeof(double),NULL);
rs->setDataBuffer(3, myBirthDate,OCCI_SQLT_DATE, sizeof(oracle::occi::Date),NULL);
while (rs->next(200)==ResultSet::DATA_AVAILABLE)
{
//cout << "Exporting batch..." << endl;
for(size_t i=0;i<rs->getNumArrayRows();i++)
{
//cout << myName[i] << endl;
cout << myAge[i] << endl;
//cout << myCash1[i] << endl;
cout << myCash2[i] << endl;
int y;
unsigned int m,d,h,mm,s;
myBirthDate[i].getDate(y,m,d,h,mm,s);
cout << y <<"-"<<m<<"-"<<s << endl;
}
}