Table ResultSet crashes when usng OCCI
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 1 of 1

Thread: Table ResultSet crashes when usng OCCI

  1. #1
    Join Date
    May 2004
    Posts
    1

    Table ResultSet crashes when usng OCCI

    I am using Oracle v9 on Win XP (Visual C++ v6). Once I get the first record, the next call to next() crashes. But it only crashes if I called getString(). getInt() is OK on multiple iterations:

    #include "stdafx.h"
    #include


    #include
    #include
    using namespace oracle:cci;
    using namespace std;

    class occicoll
    {
    private:

    Environment *env;
    Connection *conn;
    Statement *stmt;
    string tableName;
    string typeName;

    public:

    occicoll (string user, string passwd, string db)
    {
    env = Environment::createEnvironment (Environment::OBJECT);
    conn = env->createConnection (user, passwd, db);
    }

    ~occicoll ()
    {
    env->terminateConnection (conn);
    Environment::terminateEnvironment (env);
    }


    // Displaying all the rows of the table
    void displayAllRows ()
    {

    ResultSet::Status status;
    char num1[10];
    string all;

    cout << "Displaying all the rows of the table" << endl;
    stmt = conn->createStatement (
    "SELECT * FROM SCOTT.EMP1");

    ResultSet *rs = stmt->executeQuery();
    try{
    while (rs->next())
    {
    int empno = rs->getInt(1);
    // string job = rs->getString(3);
    // int mngno = rs->getInt(4);
    // string hdate = rs->getTimestamp(5);
    int salary = rs->getInt(6);
    // int comm = rs->getInt(7);
    // int dept = rs->getInt(8);

    all = "";
    itoa(empno, num1, 10);
    all = all + num1;
    cout << all << endl;



    }
    }catch(SQLException ex)
    {
    cout<<"Exception thrown for displayRow"< cout<<"Error number: "<< ex.getErrorCode() << endl;
    cout< }
    stmt->closeResultSet (rs);
    conn->terminateStatement (stmt);

    } // End of displayAllRows()



    };//end of class occicoll

    int main(int argc, char* argv[])
    {
    string user = "SYSTEM";
    string passwd = "CATS01";
    string db = "";

    try
    {

    occicoll *demo = new occicoll (user, passwd, db);

    cout << "Displaying all rows before the operations" << endl;
    demo->displayAllRows ();


    delete (demo);
    cout << "occicoll - done" << endl;
    }catch (SQLException ea)
    {
    cerr << "Error: " << ea.getMessage () << endl;
    }

    return 0;
    }
    Last edited by mdb; 05-01-2004 at 03:27 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width