Created
March 3, 2011 22:10
-
-
Save leviwilson/853723 to your computer and use it in GitHub Desktop.
OTL vs Embedded SQL Dll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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