Thanks Igor for your prompt response.
Since the call to the sqlite3_step function is inside the mySQLite3::read_*
class-function/method, I call the read_* method from Runner::read_tblName()
for each datum I need to retrieve. Now, in a while loop inside
Runner::read_tblName() I could call the mySQLite3::read_* for the data to be
retrieved, but instead of reading the next row of data, it keeps on reading
the same row again and again. Furthermore, I have no way to let
Runner::read_tblName 'know' that there is no more data, hence stopping the
while loop.
Obviously my problem is in design, but I don't have enough experience using
SQLite3 to come up with a better idea. 
My question is, really, how do you, C++ programmers, have resolved this
issue? There must be a solution.
void Runner::read_tblName() {
   .
    sql_statement = "SELECT * FROM name";
//while(there is more data){ 
// I have no-way to report to this method that there is no more data in the
bank
// I could add a flag to the mySQLite3 class and have the while loop check
on its status, 
// or a signal that would be trigger by the ending of the while loop. 

    db->setStmt(sql_statement);
    int pos = 0;
    data1 = db->read_int(pos);

    db->setStmt(sql_statement);
    pos = 1;
    data2 = db->read_str(pos);
    data3 = db->read_str(++pos);
    data4 = db->read_str(++pos);
    data5 = db->read_str(++pos);

    Glib::ustring str;
    str = apstr.format(data1);
    str += " ";
    str += data2;
    str += ". ";
    str += data3;
    str += " ";
    str += data4;
    str += " ";
    str += data5;
    apex->setException(str, FILE, METHOD, LINE);
    apex->Display();
// } <<<--- 

}
const int mySQLite3::read_int(int pos)
throw(somexception) {
    rc = sqlite3_prepare_v2(db, SQLStatement.c_str(), -1, &mystmt, NULL);
    if(rc != SQLITE_OK) {
        try {
            this->display(rc, FILE, METHOD, LINE);
        } catch(somexception e) {
            throw e;
        }
    } else {
        counter++;
    }
    rc = sqlite3_step(mystmt);
    if(rc == SQLITE_ROW ) {
        apint = sqlite3_column_int(mystmt,pos);
    }

    try {
        this->finalize();
    } catch(somexception& e) {
        throw e;
    }
    return apint;
}
const Glib::ustring& mySQLite3::read_str(const int pos)
throw(somexception) {

     //if(pos == 0) {
        rc = sqlite3_prepare_v2(db, this->SQLStatement.c_str(), -1, &mystmt,
NULL);
     //}
    if(rc != SQLITE_OK) {
        try {
            this->display(rc, FILE, METHOD, LINE);
        } catch(somexception e) {
            throw e;
        }
    } else {
        counter++;
    }

    rc = sqlite3_step(mystmt);

    if(rc == SQLITE_ROW ) {
        apstr = (const char*)sqlite3_column_text(mystmt,pos);
    }
    try {
        this->finalize();
    } catch(somexception& e) {
        throw e;
    }
    return apstr;

}

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to