In keeping with your example what you want to do is add a "done" flag to your 
write class.  So you tell it when your SQL can be executed.

Something like this:

void someClass::write2tblName() {

    stmtName = "INSERT INTO name (n_id, title, fname, mname, lname) VALUES
(?, ?, ?, ?, ?)";
    int data1 = 1;
    Glib::ustring data2, data3, data4, data5;
    data2 = "Mr";
    data3 = "Dennis";
    data4 = "Father Of C And UNIX";
    data5 = "Ritchie";
    int pos = 1;
    try {
        db->write(stmtName,pos, data1,0);
        db->write(stmtName,++pos, data2,0);
        db->write(stmtName,++pos,data3,0);
        db->write(stmtName,++pos,data4,0);
        db->write(stmtName,++pos,data5,1);
     } catch(someException){.}
}

void mySQLite3Class::write(const Glib::ustring& sql_stmt, int pos,  int data, 
int done)
)
throw(someException) {

    if (pos == 1) { // prepare statement on 1st field
      rc = sqlite3_prepare_v2(db, sql_stmt.c_str(), -1, &stmt, NULL);
      if(rc != SQLITE_OK) { throw(someException)    }
    }
    rc = sqlite3_bind_int(stmt, pos, data);
    if(rc != SQLITE_OK) { throw(someException)   }
    if (!done) return; // still have more to do so return now
    rc = sqlite3_step(stmt);
    if(rc != SQLITE_DONE) { throw(someException)   }
    sqlite3_finalize(stmt);
}


Michael D. Black
Senior Scientist
Advanced Analytics Directorate
Advanced GEOINT Solutions Operating Unit
Northrop Grumman Information Systems




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

Reply via email to