Aggiunto supporto logging transazioni ODBC
git-svn-id: svn://10.65.10.50/branches/R_10_00@23026 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
4eb316df66
commit
07a1b81dad
@ -498,6 +498,7 @@ XVTDLL XVT_ODBC xvt_odbc_get_connection(const char* dsn, const char* usr, const
|
||||
XVTDLL BOOLEAN xvt_odbc_free_connection(XVT_ODBC handle);
|
||||
XVTDLL ULONG xvt_odbc_execute(XVT_ODBC handle, const char* sql, ODBC_CALLBACK cb, void* jolly);
|
||||
XVTDLL BOOLEAN xvt_odbc_driver(XVT_ODBC handle, char* str, int max_size);
|
||||
XVTDLL BOOLEAN xvt_odbc_log_file(XVT_ODBC handle, const char* str);
|
||||
|
||||
XVTDLL BOOLEAN xvt_sql_begin(XVT_SQLDB handle);
|
||||
XVTDLL BOOLEAN xvt_sql_close(XVT_SQLDB handle);
|
||||
|
@ -110,6 +110,20 @@ BOOLEAN xvt_odbc_free_connection(XVT_ODBC handle)
|
||||
return ok;
|
||||
}
|
||||
|
||||
BOOLEAN xvt_odbc_log_file(XVT_ODBC handle, const char* str)
|
||||
{
|
||||
BOOLEAN ok = handle != NULL;
|
||||
if (ok)
|
||||
{
|
||||
wxDb* db = (wxDb*)handle;
|
||||
if (str && *str)
|
||||
ok = db->SetSqlLogging(sqlLogON, wxString(str));
|
||||
else
|
||||
db->SetSqlLogging(sqlLogOFF, wxEmptyString);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
ULONG xvt_odbc_execute(XVT_ODBC handle, const char* sql, ODBC_CALLBACK cb, void* jolly)
|
||||
{
|
||||
ULONG nCount = 0;
|
||||
@ -117,6 +131,7 @@ ULONG xvt_odbc_execute(XVT_ODBC handle, const char* sql, ODBC_CALLBACK cb, void*
|
||||
if (handle && sql && *sql)
|
||||
{
|
||||
wxDb* db = (wxDb*)handle;
|
||||
|
||||
if (cb != NULL) // Ho una vera callback?
|
||||
{
|
||||
wxDbColInf* columns = NULL;
|
||||
@ -202,10 +217,26 @@ ULONG xvt_odbc_execute(XVT_ODBC handle, const char* sql, ODBC_CALLBACK cb, void*
|
||||
}
|
||||
else
|
||||
{
|
||||
// Senza callback mi limito a contare i records
|
||||
if (db->ExecSql(sql))
|
||||
wxString cmd(sql); cmd.MakeUpper();
|
||||
|
||||
if (cmd.StartsWith("BEGIN"))
|
||||
/* DO NOTHING! */; else
|
||||
if (cmd.StartsWith("COMMIT"))
|
||||
db->CommitTrans(); else
|
||||
if (cmd.StartsWith("SELECT"))
|
||||
{
|
||||
for (nCount = 0; db->GetNext(); nCount++);
|
||||
// Senza callback mi limito a contare i records
|
||||
if (db->ExecSql(sql))
|
||||
for (nCount = 0; db->GetNext(); nCount++);
|
||||
}
|
||||
else
|
||||
{
|
||||
db->SetDebugErrorMessages(true);
|
||||
if (db->ExecSql(sql))
|
||||
nCount = 1;
|
||||
else
|
||||
nCount = -db->nativeError;
|
||||
db->SetDebugErrorMessages(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user