OK, continuing with the writing to the database, here is the driver method
for the class rapper for SQLite3.
The problem I have is that I have no control as to the exact location where
I want the data to be stored, look the table below to have a better idea of
what I mean.
My question is, is there a function that will allow me to directly plug the
data at that specific index I want?
Ultimately, what I want to do is to store all the data in ONE row. How is
this handle in SQLite3?
TIA
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);
db->write(stmtName,pos, data2);
db->write(stmtName,pos,data3);
db->write(stmtName,pos,data4);
db->write(stmtName,pos,data5);
}catch(someException){.}
}
void mySQLite3Class::write(const Glib::ustring& sql_stmt, int pos, int data
)
throw(someException) {
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) }
rc = sqlite3_step(stmt);
if(rc != SQLITE_DONE) { throw(someException) }
sqlite3_finalize(stmt);
}
void mySQLite3Class::write(const Glib::ustring& sql_stmt,int pos,
const Glib::ustring& data )
throw(someException) {
rc = sqlite3_prepare_v2(db, sql_stmt.c_str(), -1, &stmt, NULL);
if(rc != SQLITE_OK) { throw(someException) }
rc = sqlite3_bind_text(stmt, pos, data.c_str(),data.length(),
SQLITE_STATIC);
if(rc != SQLITE_OK) { throw(someException) }
rc = sqlite3_step(stmt);
if(rc != SQLITE_DONE) { throw(someException) }
sqlite3_finalize(stmt);
}
======================================
n_id | title | fname | mname | lname |
======================================
1 | | | | |
2 |Mr | | | |
3 | |Denis | | |
4 | | |Fath.. | |
5 | | | |Ritchie|
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users