문제

I want to do array fetch for DATE in oracle with following code. It compiles alright and export all other data types correctly, except for the DATE type. The program says "ora-32146 cannot peform operation on a null date".

Any one can see where I am wrong?

    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;
        }
    }
도움이 되었습니까?

해결책

Figured it out.

using rs->setDataBuffer(3, myBirthDate,OCCI_SQLT_DAT, 7,NULL);

works out all right.

No good document on OCCI...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top