Skip to content

Instantly share code, notes, and snippets.

@leviwilson
Created March 3, 2011 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leviwilson/853723 to your computer and use it in GitHub Desktop.
Save leviwilson/853723 to your computer and use it in GitHub Desktop.
OTL vs Embedded SQL Dll
extern "C"
{
int InitSQL();
int Rollback();
int Commit();
int DoMySelect(MyItem** ppItems);
};
void DoSomethingTheOldWay();
void UpdateItemTheNewWay(MyItem& myItem, otl_connect& db);
int main(int argc, char* argv[])
{
DoSomethingTheOldWay();
}
void DoSomethingTheOldWay()
{
otl_connect db;
db.rlogon("my connection info");
bool someCondition = true;
while(!someCondition)
{
InitSQL();
MyItem* myItems;
if( DoMySelect(&myItems) )
{
UpdateItemTheNewWay(myItems[0], db); // I want to update this the new way
Commit();
}
else
{
Rollback();
}
}
db.logoff();
}
void UpdateItemTheNewWay(MyItem& myItem, otl_connect& db)
{
otl_stream s(1, "update my_item set field1 = :field1<int>, field2 = :field2<int> where id = :id<int>", db);
db << myItem.field1 << myItem.field2 << myItem.id;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment