tags:

views:

187

answers:

1

I have a C++ application that uses ADO to talk to an Oracle database. I'm updating the application to support an offline documents. I've decided to implement SQLite for the local side.

I've implemented a wrapper around the ADO classes that will call the appropriate code. However, ADO's way of adding/editing/deleting rows is a bit difficult to implement for SQLite.

For ADO I'd write something like:

CADODatabase db;
CADORecordset rs( &db );
db.Open( "connection string" );
rs.Open( "select * from table1 where table1key=123" );
if (!rs.IsEOF())
{
    int value;
    rs.GetFieldValue( "field", value );
    if (value == 456)
    {
        rs.Edit();
        rs.SetFieldValue( "field", 456 );
        rs.Update();
    }
}
rs.Close();
db.Close();

For this simple example I realize that I could have just issued an update, but the real code is considerable more complex.

How would I get calls between the Edit() and Update() to actually update the data? My first thought is to have the Edit() construct a separate query and the Update() actually run it, but I'm not sure what fields will be changed nor what keys from the table to limit an update query to.