#include <database.mod/odbc.mod/.bmx/odbc.bmx.release.win32.x86.h>
struct BBString_4{BBClass_String* clas;BBULONG hash;int length;BBChar buf[4];};
struct BBString_10{BBClass_String* clas;BBULONG hash;int length;BBChar buf[10];};
struct BBString_6{BBClass_String* clas;BBULONG hash;int length;BBChar buf[6];};
struct BBString_5{BBClass_String* clas;BBULONG hash;int length;BBChar buf[5];};
struct BBString_27{BBClass_String* clas;BBULONG hash;int length;BBChar buf[27];};
struct BBString_28{BBClass_String* clas;BBULONG hash;int length;BBChar buf[28];};
struct BBString_33{BBClass_String* clas;BBULONG hash;int length;BBChar buf[33];};
struct BBString_24{BBClass_String* clas;BBULONG hash;int length;BBChar buf[24];};
struct BBString_25{BBClass_String* clas;BBULONG hash;int length;BBChar buf[25];};
struct BBString_18{BBClass_String* clas;BBULONG hash;int length;BBChar buf[18];};
struct BBString_30{BBClass_String* clas;BBULONG hash;int length;BBChar buf[30];};
struct BBString_32{BBClass_String* clas;BBULONG hash;int length;BBChar buf[32];};
struct BBString_26{BBClass_String* clas;BBULONG hash;int length;BBChar buf[26];};
struct BBString_8{BBClass_String* clas;BBULONG hash;int length;BBChar buf[8];};
static struct BBString_4 _s11={
	&bbStringClass,
	0x7e995fe2eacd8ef8,
	4,
	{46,100,115,110}
};
static struct BBString_10 _s14={
	&bbStringClass,
	0xb5694236bd9d899e,
	10,
	{59,68,65,84,65,66,65,83,69,61}
};
static struct BBString_6 _s17={
	&bbStringClass,
	0x8cefd1e2cae1bf78,
	6,
	{59,72,79,83,84,61}
};
static struct BBString_6 _s18={
	&bbStringClass,
	0x4671e02e0b7e58df,
	6,
	{59,80,79,82,84,61}
};
static struct BBString_5 _s16={
	&bbStringClass,
	0x273c473758899112,
	5,
	{59,80,87,68,61}
};
static struct BBString_6 _s15={
	&bbStringClass,
	0xbe77a70ddeba6ae9,
	6,
	{59,85,83,69,82,61}
};
static struct BBString_6 _s9={
	&bbStringClass,
	0xe549307de01c2324,
	6,
	{68,82,73,86,69,82}
};
static struct BBString_4 _s13={
	&bbStringClass,
	0xb2221c7e30226eb3,
	4,
	{68,83,78,61}
};
static struct BBString_27 _s8={
	&bbStringClass,
	0x73afbdda97baaf02,
	27,
	{69,114,114,111,114,32,97,108,108,111,99,97,116,105,110,103,32
	,99,111,110,110,101,99,116,105,111,110}
};
static struct BBString_28 _s7={
	&bbStringClass,
	0x61cbf0c72558150c,
	28,
	{69,114,114,111,114,32,97,108,108,111,99,97,116,105,110,103,32
	,101,110,118,105,114,111,110,109,101,110,116}
};
static struct BBString_33 _s3={
	&bbStringClass,
	0x863b6fd73797f5a2,
	33,
	{69,114,114,111,114,32,97,108,108,111,99,97,116,105,110,103,32
	,115,116,97,116,101,109,101,110,116,32,104,97,110,100,108,101
}
};
static struct BBString_24 _s26={
	&bbStringClass,
	0x3ec913fdf7a0d7a7,
	24,
	{69,114,114,111,114,32,98,105,110,100,105,110,103,32,112,97,114
	,97,109,101,116,101,114,115}
};
static struct BBString_28 _s1={
	&bbStringClass,
	0x98ccb0d8ca98ec90,
	28,
	{69,114,114,111,114,32,99,111,109,109,105,116,116,105,110,103,32
	,116,114,97,110,115,97,99,116,105,111,110}
};
static struct BBString_24 _s2={
	&bbStringClass,
	0xda50b5525912fa1e,
	24,
	{69,114,114,111,114,32,101,110,100,105,110,103,32,116,114,97,110
	,115,97,99,116,105,111,110}
};
static struct BBString_25 _s23={
	&bbStringClass,
	0x97c2d963e4b94776,
	25,
	{69,114,114,111,114,32,101,120,101,99,117,116,105,110,103,32,115
	,116,97,116,101,109,101,110,116}
};
static struct BBString_18 _s27={
	&bbStringClass,
	0xf56f8bb3e2dbfeca,
	18,
	{69,114,114,111,114,32,102,101,116,99,104,105,110,103,32,114,111
	,119}
};
static struct BBString_30 _s22={
	&bbStringClass,
	0x5b028ffd202f7bad,
	30,
	{69,114,114,111,114,32,102,114,101,101,105,110,103,32,115,116,97
	,116,101,109,101,110,116,32,104,97,110,100,108,101}
};
static struct BBString_32 _s24={
	&bbStringClass,
	0xb002177506c5887e,
	32,
	{69,114,114,111,114,32,103,101,116,116,105,110,103,32,99,111,108
	,117,109,110,32,100,101,115,99,114,105,112,116,105,111,110}
};
static struct BBString_24 _s19={
	&bbStringClass,
	0x8a34758eb0da4801,
	24,
	{69,114,114,111,114,32,111,112,101,110,105,110,103,32,99,111,110
	,110,101,99,116,105,111,110}
};
static struct BBString_25 _s25={
	&bbStringClass,
	0x48fa39593b31d4a4,
	25,
	{69,114,114,111,114,32,112,114,101,112,97,114,105,110,103,32,115
	,116,97,116,101,109,101,110,116}
};
static struct BBString_30 _s20={
	&bbStringClass,
	0xa04557736a983af5,
	30,
	{69,114,114,111,114,32,114,111,108,108,105,110,103,32,98,97,99
	,107,32,116,114,97,110,115,97,99,116,105,111,110}
};
static struct BBString_25 _s4={
	&bbStringClass,
	0x24bae402abe414e3,
	25,
	{69,114,114,111,114,32,115,101,116,116,105,110,103,32,99,117,114
	,115,111,114,32,116,121,112,101}
};
static struct BBString_26 _s21={
	&bbStringClass,
	0x2182482802d813a0,
	26,
	{69,114,114,111,114,32,115,116,97,114,116,105,110,103,32,116,114
	,97,110,115,97,99,116,105,111,110}
};
static struct BBString_8 _s12={
	&bbStringClass,
	0xe6e6eb196df5fefc,
	8,
	{70,73,76,69,68,83,78,61}
};
static struct BBString_4 _s28={
	&bbStringClass,
	0x84955c8aefc8f11c,
	4,
	{79,68,66,67}
};
static struct BBString_6 _s10={
	&bbStringClass,
	0x5b03365d37a754e3,
	6,
	{83,69,82,86,69,82}
};
static struct BBString_5 _s5={
	&bbStringClass,
	0xd0706d6cfa8e09d1,
	5,
	{84,65,66,76,69}
};
struct BBDebugScope_12{int kind; const char *name; BBDebugDecl decls[13]; };
struct BBDebugScope_16{int kind; const char *name; BBDebugDecl decls[17]; };
struct BBDebugScope_2{int kind; const char *name; BBDebugDecl decls[3]; };
void _database_odbc_TODBCDatabaseLoader_New(struct database_odbc_TODBCDatabaseLoader_obj* o) {
	_database_core_TDatabaseLoader_New((struct database_core_TDatabaseLoader_obj*)o);
	o->clas = &database_odbc_TODBCDatabaseLoader;
	o->_database_core_tdatabaseloader__type =((BBString*)&_s28);
}
struct database_core_TDBConnection_obj* _database_odbc_TODBCDatabaseLoader_LoadDatabase_SSiSSSS(struct database_odbc_TODBCDatabaseLoader_obj* o,BBSTRING bbt_dbname,BBSTRING bbt_host,BBINT bbt_port,BBSTRING bbt_user,BBSTRING bbt_password,BBSTRING bbt_server,BBSTRING bbt_options){
	return (struct database_core_TDBConnection_obj*)database_odbc_TDBODBC_Create_TTDBConnection_SSiSSSS(bbt_dbname,bbt_host,bbt_port,bbt_user,bbt_password,bbt_server,bbt_options);
}
struct BBDebugScope_2 database_odbc_TODBCDatabaseLoader_scope ={
	BBDEBUGSCOPE_USERTYPE,
	"TODBCDatabaseLoader",
	{
		{
			BBDEBUGDECL_TYPEMETHOD,
			"New",
			"()",
			.func_ptr=(BBFuncPtr)&_database_odbc_TODBCDatabaseLoader_New
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"LoadDatabase",
			"($,$,i,$,$,$,$):TDBConnection",
			.func_ptr=(BBFuncPtr)&_database_odbc_TODBCDatabaseLoader_LoadDatabase_SSiSSSS
		},
		{
			BBDEBUGDECL_END
		}
	}
};
struct BBClass_database_odbc_TODBCDatabaseLoader database_odbc_TODBCDatabaseLoader={
	&database_core_TDatabaseLoader,
	bbObjectFree,
	(BBDebugScope*)&database_odbc_TODBCDatabaseLoader_scope,
	sizeof(struct database_odbc_TODBCDatabaseLoader_obj),
	(void (*)(BBOBJECT))_database_odbc_TODBCDatabaseLoader_New,
	bbObjectDtor,
	bbObjectToString,
	bbObjectCompare,
	bbObjectSendMessage,
	0,
	0,
	0
	,0
	,sizeof(void*)
	,_database_odbc_TODBCDatabaseLoader_LoadDatabase_SSiSSSS
};

void _database_odbc_TDBODBC_New(struct database_odbc_TDBODBC_obj* o) {
	_database_core_TDBConnection_New((struct database_core_TDBConnection_obj*)o);
	o->clas = &database_odbc_TDBODBC;
	o->_database_odbc_tdbodbc_envhandle = 0;
}
void _database_odbc_TDBODBC_Delete(struct database_odbc_TDBODBC_obj* o) {
	_database_core_TDBConnection_Delete((struct database_core_TDBConnection_obj*)o);
}
struct database_core_TDBConnection_obj* database_odbc_TDBODBC_Create_TTDBConnection_SSiSSSS(BBSTRING bbt_dbname,BBSTRING bbt_host,BBINT bbt_port,BBSTRING bbt_user,BBSTRING bbt_password,BBSTRING bbt_server,BBSTRING bbt_options){
	struct database_odbc_TDBODBC_obj* bbt_this=(struct database_odbc_TDBODBC_obj*)(struct database_odbc_TDBODBC_obj*)bbObjectNew((BBClass *)&database_odbc_TDBODBC);
	(bbt_this)->clas->m_Init_SSiSSSS((struct database_core_TDBConnection_obj*)bbt_this,bbt_dbname,bbt_host,bbt_port,bbt_user,bbt_password,bbt_server,bbt_options);
	if(bbt_this->_database_core_tdbconnection__dbname != &bbEmptyString){
		(bbt_this)->clas->m_open_SS((struct database_odbc_TDBODBC_obj*)bbt_this,bbt_user,bbt_password);
	}
	return (struct database_core_TDBConnection_obj*)((struct database_core_TDBConnection_obj*)bbObjectDowncast((BBOBJECT)bbt_this,(BBClass*)&database_core_TDBConnection));
}
void _database_odbc_TDBODBC_close(struct database_odbc_TDBODBC_obj* o){
	o->_database_core_tdbconnection__isopen =0;
	if(o->_database_core_tdbconnection_handle ){
		bmx_odbc_disconnectAndFree(o->_database_core_tdbconnection_handle );
		o->_database_core_tdbconnection_handle =0;
	}
	if(o->_database_odbc_tdbodbc_envhandle ){
		bmx_odbc_freeEnvHandle(o->_database_odbc_tdbodbc_envhandle );
		o->_database_odbc_tdbodbc_envhandle =0;
	}
}
BBINT _database_odbc_TDBODBC_commit(struct database_odbc_TDBODBC_obj* o){
	if(!(o->_database_core_tdbconnection__isopen !=0)){
		return 0;
	}
	BBINT bbt_result=bmx_odbc_commitTransaction(o->_database_core_tdbconnection_handle );
	if(database_odbc_isSQLError(bbt_result)!=0){
		((struct database_odbc_TDBODBC_obj*)o)->clas->m_processError_iSipb((struct database_odbc_TDBODBC_obj*)o,2,((BBString*)&_s1),1,0);
		return 0;
	}
	bbt_result=bmx_odbc_toggleTransaction(o->_database_core_tdbconnection_handle ,1);
	if(database_odbc_isSQLError(bbt_result)!=0){
		((struct database_odbc_TDBODBC_obj*)o)->clas->m_processError_iSipb((struct database_odbc_TDBODBC_obj*)o,2,((BBString*)&_s2),1,0);
		return 0;
	}
	return 1;
}
BBARRAY _database_odbc_TDBODBC_getTables(struct database_odbc_TDBODBC_obj* o){
	BBARRAY bbt_list=(&bbEmptyArray);
	if(!(o->_database_core_tdbconnection__isopen !=0)){
		return bbt_list;
	}
	BBBYTE* bbt_stmtHandle=0;
	BBINT bbt_result=bmx_odbc_SQLAllocHandle(3,o->_database_core_tdbconnection_handle ,(&bbt_stmtHandle));
	if(database_odbc_isSQLError(bbt_result)!=0){
		((struct database_odbc_TDBODBC_obj*)o)->clas->m_processError_iSipb((struct database_odbc_TDBODBC_obj*)o,2,((BBString*)&_s3),3,0);
		if(bbt_stmtHandle){
			bbt_result=bmx_odbc_freeStmtHandle(bbt_stmtHandle);
		}
		return bbt_list;
	}
	bbt_result=bmx_odbc_setForwardCursor(bbt_stmtHandle);
	if(database_odbc_isSQLError(bbt_result)!=0){
		((struct database_odbc_TDBODBC_obj*)o)->clas->m_processError_iSipb((struct database_odbc_TDBODBC_obj*)o,3,((BBString*)&_s4),3,bbt_stmtHandle);
		bbt_result=bmx_odbc_freeStmtHandle(bbt_stmtHandle);
		return bbt_list;
	}
	BBBYTE* bbt_ = (BBBYTE*)bbStringToCString((BBString*)&_s5);
	bbt_result=bmx_odbc_SQLTables(bbt_stmtHandle,bbt_,5);
	bbMemFree(bbt_);
	if(database_odbc_isSQLError(bbt_result)!=0){
		((struct database_odbc_TDBODBC_obj*)o)->clas->m_processError_iSipb((struct database_odbc_TDBODBC_obj*)o,3,((BBString*)&_s4),3,bbt_stmtHandle);
		bbt_result=bmx_odbc_freeStmtHandle(bbt_stmtHandle);
		return bbt_list;
	}
	bbt_result=bmx_odbc_SQLFetchScroll(bbt_stmtHandle);
	struct brl_linkedlist_TList_obj* bbt_tables=(struct brl_linkedlist_TList_obj*)(struct brl_linkedlist_TList_obj*)bbObjectNew((BBClass *)&brl_linkedlist_TList);
	while(bbt_result==0){
		BBINT bbt_lenIndicator=0;
		BBBYTE bbt_buffer[256]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
		struct brl_stringbuilder_TStringBuilder_obj* bbt_sb=(struct brl_stringbuilder_TStringBuilder_obj*)(struct brl_stringbuilder_TStringBuilder_obj*)bbObjectNew((BBClass *)&brl_stringbuilder_TStringBuilder);
		while(1){
			bbt_result=bmx_odbc_SQLGetData_string(bbt_stmtHandle,3,(bbt_buffer),256,(&bbt_lenIndicator));
			if((database_odbc_isSQLError(bbt_result)!=0) || (bbt_result==100)){
				break;
			}
			if((bbt_lenIndicator==-1) || (bbt_lenIndicator==-4)){
				break;
			}
			BBINT bbt_actualSize=0;
			if(bbt_result==1){
				bbt_actualSize=256;
			}else{
				bbt_actualSize=bbt_lenIndicator;
			}
			(bbt_sb)->clas->m_AppendUTF8Bytes_pbi((struct brl_stringbuilder_TStringBuilder_obj*)bbt_sb,(bbt_buffer),bbt_actualSize);
			if(bbt_lenIndicator<256){
				break;
			}
		}
		(bbt_tables)->clas->m_AddLast_TObject((struct brl_linkedlist_TList_obj*)bbt_tables,(BBOBJECT)(bbt_sb)->clas->ToString((struct brl_stringbuilder_TStringBuilder_obj*)bbt_sb));
		bbt_result=bmx_odbc_SQLFetchScroll(bbt_stmtHandle);
	}
	if((bbt_tables)->clas->m_Count((struct brl_linkedlist_TList_obj*)bbt_tables)>0){
		bbt_list=bbArrayNew1D("$", (bbt_tables)->clas->m_Count((struct brl_linkedlist_TList_obj*)bbt_tables));
		BBINT bbt_i=0;
		struct brl_linkedlist_TListEnum_obj* bbt_2=(struct brl_linkedlist_TListEnum_obj*)(bbt_tables)->clas->m_ObjectEnumerator((struct brl_linkedlist_TList_obj*)bbt_tables);
		while((bbt_2)->clas->m_HasNext((struct brl_linkedlist_TListEnum_obj*)bbt_2)!=0){
			BBOBJECT bbt_3=(BBOBJECT)(bbt_2)->clas->m_NextObject((struct brl_linkedlist_TListEnum_obj*)bbt_2);
			if(bbObjectIsString((BBOBJECT)bbt_3)==0){
				continue;
			}
			BBSTRING bbt_s=((BBString *)bbObjectStringcast((BBOBJECT)bbt_3));
			((BBSTRING*)BBARRAYDATA(bbt_list,1))[((BBUINT)bbt_i)]=bbt_s;
			bbt_i+=1;
		}
	}
	bbt_result=bmx_odbc_freeStmtHandle(bbt_stmtHandle);
	return bbt_list;
}
struct database_core_TDBTable_obj* _database_odbc_TDBODBC_getTableInfo_Si(struct database_odbc_TDBODBC_obj* o,BBSTRING bbt_tableName,BBINT bbt_withDDL){
	return (struct database_core_TDBTable_obj*)((struct database_core_TDBTable_obj*)&bbNullObject);
}
BBINT _database_odbc_TDBODBC_open_SS(struct database_odbc_TDBODBC_obj* o,BBSTRING bbt_user,BBSTRING bbt_pass){
	if(o->_database_core_tdbconnection__isopen !=0){
		((struct database_odbc_TDBODBC_obj*)o)->clas->m_close((struct database_odbc_TDBODBC_obj*)o);
	}
	if(bbt_user!= &bbEmptyString){
		o->_database_core_tdbconnection__user =bbt_user;
	}
	if(bbt_pass!= &bbEmptyString){
		o->_database_core_tdbconnection__password =bbt_pass;
	}
	BBINT bbt_result=bmx_odbc_SQLAllocHandle(1,0,(&o->_database_odbc_tdbodbc_envhandle ));
	if(database_odbc_isSQLError(bbt_result)!=0){
		((struct database_odbc_TDBODBC_obj*)o)->clas->m_processError_iSipb((struct database_odbc_TDBODBC_obj*)o,1,((BBString*)&_s7),2,0);
		return 0;
	}
	bmx_odbc_setattr_odbc3(o->_database_odbc_tdbodbc_envhandle );
	bbt_result=bmx_odbc_SQLAllocHandle(2,o->_database_odbc_tdbodbc_envhandle ,(&o->_database_core_tdbconnection_handle ));
	if(database_odbc_isSQLError(bbt_result)!=0){
		((struct database_odbc_TDBODBC_obj*)o)->clas->m_processError_iSipb((struct database_odbc_TDBODBC_obj*)o,2,((BBString*)&_s8),2,0);
		return 0;
	}
	BBSTRING bbt_connect=((BBString*)&bbEmptyString);
	if((bbStringContains((BBSTRING)o->_database_core_tdbconnection__server ,((BBString*)&_s9))!=0) || (bbStringContains((BBSTRING)o->_database_core_tdbconnection__server ,((BBString*)&_s10))!=0)){
		bbt_connect=o->_database_core_tdbconnection__server ;
	}else{
		if(bbStringContains((BBSTRING)o->_database_core_tdbconnection__server ,((BBString*)&_s11))!=0){
			bbt_connect=bbStringConcat(((BBString*)&_s12),o->_database_core_tdbconnection__server );
		}else{
			bbt_connect=bbStringConcat(((BBString*)&_s13),o->_database_core_tdbconnection__server );
		}
	}
	if((o->_database_core_tdbconnection__dbname != &bbEmptyString) && ((o->_database_core_tdbconnection__dbname ->length)>0)){
		bbt_connect=bbStringConcat(bbt_connect,(bbStringConcat(((BBString*)&_s14),o->_database_core_tdbconnection__dbname )));
	}
	if(o->_database_core_tdbconnection__user != &bbEmptyString){
		bbt_connect=bbStringConcat(bbt_connect,(bbStringConcat(((BBString*)&_s15),o->_database_core_tdbconnection__user )));
	}
	if(o->_database_core_tdbconnection__password != &bbEmptyString){
		bbt_connect=bbStringConcat(bbt_connect,(bbStringConcat(((BBString*)&_s16),o->_database_core_tdbconnection__password )));
	}
	if(o->_database_core_tdbconnection__host != &bbEmptyString){
		bbt_connect=bbStringConcat(bbt_connect,(bbStringConcat(((BBString*)&_s17),o->_database_core_tdbconnection__host )));
	}
	if(o->_database_core_tdbconnection__port !=0){
		bbt_connect=bbStringConcat(bbt_connect,(bbStringConcat(((BBString*)&_s18),bbStringFromInt(o->_database_core_tdbconnection__port ))));
	}
	BBBYTE* bbt_conv=bbStringToUTF8String((BBSTRING)bbt_connect);
	bbt_result=bmx_odbc_SQLDriverConnect(o->_database_core_tdbconnection_handle ,bbt_conv,((BBINT)strlen((const char*)bbt_conv)));
	bbMemFree((void*)bbt_conv);
	if(database_odbc_isSQLError(bbt_result)!=0){
		((struct database_odbc_TDBODBC_obj*)o)->clas->m_processError_iSipb((struct database_odbc_TDBODBC_obj*)o,2,((BBString*)&_s19),2,0);
		return 0;
	}
	o->_database_core_tdbconnection__isopen =1;
	return 1;
}
BBINT _database_odbc_TDBODBC_rollback(struct database_odbc_TDBODBC_obj* o){
	if(!(o->_database_core_tdbconnection__isopen !=0)){
		return 0;
	}
	BBINT bbt_result=bmx_odbc_rollbackTransaction(o->_database_core_tdbconnection_handle );
	if(database_odbc_isSQLError(bbt_result)!=0){
		((struct database_odbc_TDBODBC_obj*)o)->clas->m_processError_iSipb((struct database_odbc_TDBODBC_obj*)o,2,((BBString*)&_s20),1,0);
		return 0;
	}
	bbt_result=bmx_odbc_toggleTransaction(o->_database_core_tdbconnection_handle ,1);
	if(database_odbc_isSQLError(bbt_result)!=0){
		((struct database_odbc_TDBODBC_obj*)o)->clas->m_processError_iSipb((struct database_odbc_TDBODBC_obj*)o,2,((BBString*)&_s2),1,0);
		return 0;
	}
	return 1;
}
BBINT _database_odbc_TDBODBC_startTransaction(struct database_odbc_TDBODBC_obj* o){
	if(!(o->_database_core_tdbconnection__isopen !=0)){
		return 0;
	}
	BBINT bbt_result=bmx_odbc_toggleTransaction(o->_database_core_tdbconnection_handle ,0);
	if(database_odbc_isSQLError(bbt_result)!=0){
		((struct database_odbc_TDBODBC_obj*)o)->clas->m_processError_iSipb((struct database_odbc_TDBODBC_obj*)o,2,((BBString*)&_s21),1,0);
		return 0;
	}
	return 1;
}
BBBYTE* _database_odbc_TDBODBC_databaseHandle(struct database_odbc_TDBODBC_obj* o){
	return 0;
}
struct database_core_TQueryResultSet_obj* _database_odbc_TDBODBC_createResultSet(struct database_odbc_TDBODBC_obj* o){
	return (struct database_core_TQueryResultSet_obj*)database_odbc_TODBCResultSet_Create_TTQueryResultSet_TTDBConnectionS((struct database_core_TDBConnection_obj*)((struct database_core_TDBConnection_obj*)bbObjectDowncast((BBOBJECT)o,(BBClass*)&database_core_TDBConnection)),(&bbEmptyString));
}
BBSTRING _database_odbc_TDBODBC_nativeErrorMessage_i(struct database_odbc_TDBODBC_obj* o,BBINT bbt_err){
	return ((BBString*)&bbEmptyString);
}
void _database_odbc_TDBODBC_processError_iSipb(struct database_odbc_TDBODBC_obj* o,BBINT bbt_kind,BBSTRING bbt_msg,BBINT bbt_errType,BBBYTE* bbt_h){
	BBINT bbt_code=0;
	BBSTRING bbt_err=((BBString*)&bbEmptyString);
	BBINT bbt_=bbt_kind;
	if(bbt_==1){
		bbt_err=bmx_odbc_envError(o->_database_odbc_tdbodbc_envhandle ,(&bbt_code));
	}else{
		if(bbt_==2){
			bbt_err=bmx_odbc_connError(o->_database_core_tdbconnection_handle ,(&bbt_code));
		}else{
			if(bbt_==3){
				bbt_err=bmx_odbc_stmtError(bbt_h,(&bbt_code));
			}
		}
	}
	((struct database_core_TDBConnection_obj*)o)->clas->m_setError_SSii((struct database_core_TDBConnection_obj*)o,bbt_msg,bbt_err,bbt_errType,bbt_code);
}
BBINT _database_odbc_TDBODBC_hasPrepareSupport(struct database_odbc_TDBODBC_obj* o){
	return 1;
}
BBINT _database_odbc_TDBODBC_hasTransactionSupport(struct database_odbc_TDBODBC_obj* o){
	return 1;
}
struct BBDebugScope_16 database_odbc_TDBODBC_scope ={
	BBDEBUGSCOPE_USERTYPE,
	"TDBODBC",
	{
		{
			BBDEBUGDECL_FIELD,
			"envHandle",
			"*b",
			.field_offset=offsetof(struct database_odbc_TDBODBC_obj,_database_odbc_tdbodbc_envhandle)
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"New",
			"()",
			.func_ptr=(BBFuncPtr)&_database_odbc_TDBODBC_New
		},
		{
			BBDEBUGDECL_TYPEFUNCTION,
			"Create",
			"($,$,i,$,$,$,$):TDBConnection",
			.func_ptr=(BBFuncPtr)&database_odbc_TDBODBC_Create_TTDBConnection_SSiSSSS
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"close",
			"()",
			.func_ptr=(BBFuncPtr)&_database_odbc_TDBODBC_close
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"commit",
			"()i",
			.func_ptr=(BBFuncPtr)&_database_odbc_TDBODBC_commit
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"getTables",
			"()[]$",
			.func_ptr=(BBFuncPtr)&_database_odbc_TDBODBC_getTables
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"getTableInfo",
			"($,i):TDBTable",
			.func_ptr=(BBFuncPtr)&_database_odbc_TDBODBC_getTableInfo_Si
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"open",
			"($,$)i",
			.func_ptr=(BBFuncPtr)&_database_odbc_TDBODBC_open_SS
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"rollback",
			"()i",
			.func_ptr=(BBFuncPtr)&_database_odbc_TDBODBC_rollback
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"startTransaction",
			"()i",
			.func_ptr=(BBFuncPtr)&_database_odbc_TDBODBC_startTransaction
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"databaseHandle",
			"()*b",
			.func_ptr=(BBFuncPtr)&_database_odbc_TDBODBC_databaseHandle
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"createResultSet",
			"():TQueryResultSet",
			.func_ptr=(BBFuncPtr)&_database_odbc_TDBODBC_createResultSet
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"nativeErrorMessage",
			"(i)$",
			.func_ptr=(BBFuncPtr)&_database_odbc_TDBODBC_nativeErrorMessage_i
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"processError",
			"(i,$,i,*b)",
			.func_ptr=(BBFuncPtr)&_database_odbc_TDBODBC_processError_iSipb
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"hasPrepareSupport",
			"()i",
			.func_ptr=(BBFuncPtr)&_database_odbc_TDBODBC_hasPrepareSupport
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"hasTransactionSupport",
			"()i",
			.func_ptr=(BBFuncPtr)&_database_odbc_TDBODBC_hasTransactionSupport
		},
		{
			BBDEBUGDECL_END
		}
	}
};
struct BBClass_database_odbc_TDBODBC database_odbc_TDBODBC={
	&database_core_TDBConnection,
	bbObjectFree,
	(BBDebugScope*)&database_odbc_TDBODBC_scope,
	sizeof(struct database_odbc_TDBODBC_obj),
	(void (*)(BBOBJECT))_database_odbc_TDBODBC_New,
	(void (*)(BBOBJECT))_database_odbc_TDBODBC_Delete,
	bbObjectToString,
	bbObjectCompare,
	bbObjectSendMessage,
	0,
	0,
	sizeof(BBBYTE*)
	,0
	,offsetof(struct database_odbc_TDBODBC_obj,_database_odbc_tdbodbc_envhandle)
	,database_odbc_TDBODBC_Create_TTDBConnection_SSiSSSS
	,_database_core_TDBConnection_Init_SSiSSSS
	,_database_odbc_TDBODBC_close
	,_database_odbc_TDBODBC_commit
	,_database_odbc_TDBODBC_getTables
	,_database_odbc_TDBODBC_getTableInfo_Si
	,_database_odbc_TDBODBC_open_SS
	,_database_odbc_TDBODBC_rollback
	,_database_odbc_TDBODBC_startTransaction
	,_database_core_TDBConnection_executeQuery_S
	,_database_core_TDBConnection_isOpen
	,_database_core_TDBConnection_getDatabaseName
	,_database_core_TDBConnection_getHost
	,_database_core_TDBConnection_getPortNumber
	,_database_core_TDBConnection_error
	,_database_core_TDBConnection_resetError
	,_database_core_TDBConnection_hasError
	,_database_core_TDBConnection_setError_SSii
	,_database_odbc_TDBODBC_databaseHandle
	,_database_odbc_TDBODBC_createResultSet
	,_database_odbc_TDBODBC_nativeErrorMessage_i
	,_database_odbc_TDBODBC_hasPrepareSupport
	,_database_odbc_TDBODBC_hasTransactionSupport
	,_database_core_TDBConnection_free
	,_database_odbc_TDBODBC_processError_iSipb
};

void _database_odbc_TODBCResultSet_New(struct database_odbc_TODBCResultSet_obj* o) {
	_database_core_TQueryResultSet_New((struct database_core_TQueryResultSet_obj*)o);
	o->clas = &database_odbc_TODBCResultSet;
}
void _database_odbc_TODBCResultSet_Delete(struct database_odbc_TODBCResultSet_obj* o) {
	_database_core_TQueryResultSet_Delete((struct database_core_TQueryResultSet_obj*)o);
}
struct database_core_TQueryResultSet_obj* database_odbc_TODBCResultSet_Create_TTQueryResultSet_TTDBConnectionS(struct database_core_TDBConnection_obj* bbt_db,BBSTRING bbt_sql){
	struct database_odbc_TODBCResultSet_obj* bbt_this=(struct database_odbc_TODBCResultSet_obj*)(struct database_odbc_TODBCResultSet_obj*)bbObjectNew((BBClass *)&database_odbc_TODBCResultSet);
	(bbt_this)->clas->m_Init_TTDBConnectionS((struct database_core_TQueryResultSet_obj*)bbt_this,(struct database_core_TDBConnection_obj*)bbt_db,bbt_sql);
	bbt_this->_database_core_tqueryresultset_rec =(struct database_core_TQueryRecord_obj*)database_core_TQueryRecord_Create_TTQueryRecord();
	return (struct database_core_TQueryResultSet_obj*)((struct database_core_TQueryResultSet_obj*)bbObjectDowncast((BBOBJECT)bbt_this,(BBClass*)&database_core_TQueryResultSet));
}
BBINT _database_odbc_TODBCResultSet_executeQuery_S(struct database_odbc_TODBCResultSet_obj* o,BBSTRING bbt_statement){
	o->_database_core_tqueryresultset__isactive =0;
	o->_database_core_tqueryresultset_index =-1;
	(o->_database_core_tqueryresultset_rec )->clas->m_clear((struct database_core_TQueryRecord_obj*)o->_database_core_tqueryresultset_rec );
	BBINT bbt_result=0;
	if(o->_database_core_tqueryresultset_stmthandle ){
		bbt_result=bmx_odbc_freeStmtHandle(o->_database_core_tqueryresultset_stmthandle );
		o->_database_core_tqueryresultset_stmthandle =0;
		if(database_odbc_isSQLError(bbt_result)!=0){
			struct database_odbc_TDBODBC_obj* bbt_;
			(((struct database_odbc_TDBODBC_obj*)(bbt_ = ((struct database_odbc_TDBODBC_obj*)bbObjectDowncast((BBOBJECT)o->_database_core_tqueryresultset_conn ,(BBClass*)&database_odbc_TDBODBC))))->clas)->m_processError_iSipb((struct database_odbc_TDBODBC_obj*)bbt_,3,((BBString*)&_s22),3,o->_database_core_tqueryresultset_stmthandle );
			return 0;
		}
	}
	bbt_result=bmx_odbc_SQLAllocHandle(3,o->_database_core_tqueryresultset_conn ->_database_core_tdbconnection_handle ,(&o->_database_core_tqueryresultset_stmthandle ));
	if(database_odbc_isSQLError(bbt_result)!=0){
		struct database_odbc_TDBODBC_obj* bbt_2;
		(((struct database_odbc_TDBODBC_obj*)(bbt_2 = ((struct database_odbc_TDBODBC_obj*)bbObjectDowncast((BBOBJECT)o->_database_core_tqueryresultset_conn ,(BBClass*)&database_odbc_TDBODBC))))->clas)->m_processError_iSipb((struct database_odbc_TDBODBC_obj*)bbt_2,2,((BBString*)&_s3),3,0);
		return 0;
	}
	bbt_result=bmx_odbc_setForwardCursor(o->_database_core_tqueryresultset_stmthandle );
	if(database_odbc_isSQLError(bbt_result)!=0){
		struct database_odbc_TDBODBC_obj* bbt_3;
		(((struct database_odbc_TDBODBC_obj*)(bbt_3 = ((struct database_odbc_TDBODBC_obj*)bbObjectDowncast((BBOBJECT)o->_database_core_tqueryresultset_conn ,(BBClass*)&database_odbc_TDBODBC))))->clas)->m_processError_iSipb((struct database_odbc_TDBODBC_obj*)bbt_3,3,((BBString*)&_s4),3,o->_database_core_tqueryresultset_stmthandle );
		return 0;
	}
	BBBYTE* bbt_q=bbStringToUTF8String((BBSTRING)bbt_statement);
	bbt_result=bmx_odbc_execute(o->_database_core_tqueryresultset_stmthandle ,bbt_q,((BBINT)strlen((const char*)bbt_q)));
	bbMemFree((void*)bbt_q);
	if(database_odbc_isSQLError(bbt_result)!=0){
		struct database_odbc_TDBODBC_obj* bbt_4;
		(((struct database_odbc_TDBODBC_obj*)(bbt_4 = ((struct database_odbc_TDBODBC_obj*)bbObjectDowncast((BBOBJECT)o->_database_core_tqueryresultset_conn ,(BBClass*)&database_odbc_TDBODBC))))->clas)->m_processError_iSipb((struct database_odbc_TDBODBC_obj*)bbt_4,3,((BBString*)&_s23),3,o->_database_core_tqueryresultset_stmthandle );
		return 0;
	}
	BBINT bbt_fieldCount=0;
	bmx_odbc_SQLNumResultCols(o->_database_core_tqueryresultset_stmthandle ,(&bbt_fieldCount));
	((struct database_odbc_TODBCResultSet_obj*)o)->clas->m_initRecord_i((struct database_odbc_TODBCResultSet_obj*)o,bbt_fieldCount);
	if(bbt_fieldCount!=0){
		BBINT bbt_bufferLength=256;
		BBBYTE bbt_columnName[256]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
		BBINT bbt_nameLength=0;
		BBINT bbt_dataType=0;
		BBINT bbt_columnSize=0;
		BBINT bbt_decimalDigits=0;
		BBINT bbt_nullable=0;
		{
			BBINT bbt_i=0;
			BBINT bbt_5=bbt_fieldCount;
			for(;(bbt_i<bbt_5);bbt_i=(bbt_i+1)){
				bbt_result=bmx_odbc_SQLDescribeCol(o->_database_core_tqueryresultset_stmthandle ,(bbt_i+1),(bbt_columnName),bbt_bufferLength,(&bbt_nameLength),(&bbt_dataType),(&bbt_columnSize),(&bbt_decimalDigits),(&bbt_nullable));
				if(database_odbc_isSQLError(bbt_result)!=0){
					struct database_odbc_TDBODBC_obj* bbt_6;
					(((struct database_odbc_TDBODBC_obj*)(bbt_6 = ((struct database_odbc_TDBODBC_obj*)bbObjectDowncast((BBOBJECT)o->_database_core_tqueryresultset_conn ,(BBClass*)&database_odbc_TDBODBC))))->clas)->m_processError_iSipb((struct database_odbc_TDBODBC_obj*)bbt_6,3,((BBString*)&_s24),3,o->_database_core_tqueryresultset_stmthandle );
					return 0;
				}
				struct database_core_TQueryField_obj* bbt_qf=(struct database_core_TQueryField_obj*)database_core_TQueryField_Create_TTQueryField_Si(bbStringFromUTF8Bytes((bbt_columnName),bbt_nameLength),o->clas->f_dbTypeFromNative_i_Sii((&bbEmptyString),bbt_dataType,0));
				if(bbt_columnSize==0){
					bbt_qf->_database_core_tqueryfield_length =-1;
				}else{
					bbt_qf->_database_core_tqueryfield_length =bbt_columnSize;
				}
				if(bbt_decimalDigits==0){
					bbt_qf->_database_core_tqueryfield_precision =-1;
				}else{
					bbt_qf->_database_core_tqueryfield_precision =bbt_decimalDigits;
				}
				if(bbt_nullable==1){
					bbt_qf->_database_core_tqueryfield_nullable =1;
				}else{
					if(bbt_nullable==0){
						bbt_qf->_database_core_tqueryfield_nullable =0;
					}
				}
				(o->_database_core_tqueryresultset_rec )->clas->m_setField_iTTQueryField((struct database_core_TQueryRecord_obj*)o->_database_core_tqueryresultset_rec ,bbt_i,(struct database_core_TQueryField_obj*)bbt_qf);
			}
		}
	}
	o->_database_core_tqueryresultset__isactive =1;
	return 1;
}
BBINT _database_odbc_TODBCResultSet_prepare_S(struct database_odbc_TODBCResultSet_obj* o,BBSTRING bbt_statement){
	o->_database_core_tqueryresultset__isactive =0;
	o->_database_core_tqueryresultset_index =-1;
	(o->_database_core_tqueryresultset_rec )->clas->m_clear((struct database_core_TQueryRecord_obj*)o->_database_core_tqueryresultset_rec );
	BBINT bbt_result=0;
	if(o->_database_core_tqueryresultset_stmthandle ){
		bbt_result=bmx_odbc_freeStmtHandle(o->_database_core_tqueryresultset_stmthandle );
		o->_database_core_tqueryresultset_stmthandle =0;
		if(database_odbc_isSQLError(bbt_result)!=0){
			struct database_odbc_TDBODBC_obj* bbt_;
			(((struct database_odbc_TDBODBC_obj*)(bbt_ = ((struct database_odbc_TDBODBC_obj*)bbObjectDowncast((BBOBJECT)o->_database_core_tqueryresultset_conn ,(BBClass*)&database_odbc_TDBODBC))))->clas)->m_processError_iSipb((struct database_odbc_TDBODBC_obj*)bbt_,3,((BBString*)&_s22),3,o->_database_core_tqueryresultset_stmthandle );
			return 0;
		}
	}
	bbt_result=bmx_odbc_SQLAllocHandle(3,o->_database_core_tqueryresultset_conn ->_database_core_tdbconnection_handle ,(&o->_database_core_tqueryresultset_stmthandle ));
	if(database_odbc_isSQLError(bbt_result)!=0){
		struct database_odbc_TDBODBC_obj* bbt_2;
		(((struct database_odbc_TDBODBC_obj*)(bbt_2 = ((struct database_odbc_TDBODBC_obj*)bbObjectDowncast((BBOBJECT)o->_database_core_tqueryresultset_conn ,(BBClass*)&database_odbc_TDBODBC))))->clas)->m_processError_iSipb((struct database_odbc_TDBODBC_obj*)bbt_2,2,((BBString*)&_s3),3,0);
		return 0;
	}
	bbt_result=bmx_odbc_setForwardCursor(o->_database_core_tqueryresultset_stmthandle );
	if(database_odbc_isSQLError(bbt_result)!=0){
		struct database_odbc_TDBODBC_obj* bbt_3;
		(((struct database_odbc_TDBODBC_obj*)(bbt_3 = ((struct database_odbc_TDBODBC_obj*)bbObjectDowncast((BBOBJECT)o->_database_core_tqueryresultset_conn ,(BBClass*)&database_odbc_TDBODBC))))->clas)->m_processError_iSipb((struct database_odbc_TDBODBC_obj*)bbt_3,3,((BBString*)&_s4),3,o->_database_core_tqueryresultset_stmthandle );
		return 0;
	}
	BBBYTE* bbt_q=bbStringToUTF8String((BBSTRING)bbt_statement);
	bbt_result=bmx_odbc_prepare(o->_database_core_tqueryresultset_stmthandle ,bbt_q,((BBINT)strlen((const char*)bbt_q)));
	bbMemFree((void*)bbt_q);
	if(database_odbc_isSQLError(bbt_result)!=0){
		struct database_odbc_TDBODBC_obj* bbt_4;
		(((struct database_odbc_TDBODBC_obj*)(bbt_4 = ((struct database_odbc_TDBODBC_obj*)bbObjectDowncast((BBOBJECT)o->_database_core_tqueryresultset_conn ,(BBClass*)&database_odbc_TDBODBC))))->clas)->m_processError_iSipb((struct database_odbc_TDBODBC_obj*)bbt_4,3,((BBString*)&_s25),3,o->_database_core_tqueryresultset_stmthandle );
		return 0;
	}
	return 1;
}
BBINT _database_odbc_TODBCResultSet_execute(struct database_odbc_TODBCResultSet_obj* o){
	o->_database_core_tqueryresultset__isactive =0;
	o->_database_core_tqueryresultset_index =-1;
	if(!(o->_database_core_tqueryresultset_stmthandle )){
		return 0;
	}
	BBINT bbt_result=0;
	BBARRAY bbt_values=o->_database_core_tqueryresultset_boundvalues ;
	BBARRAY bbt_strings=(&bbEmptyArray);
	BBINT bbt_paramCount=0;
	if(bbt_values!= &bbEmptyArray){
		bbt_paramCount=o->_database_core_tqueryresultset_bindcount ;
		BBARRAY bbt_isNull=bbArrayNew1D("i", bbt_paramCount);
		bbt_strings=bbArrayNew1D("*b", bbt_paramCount);
		{
			BBINT bbt_i=0;
			BBINT bbt_=bbt_paramCount;
			for(;(bbt_i<bbt_);bbt_i=(bbt_i+1)){
				((BBINT*)BBARRAYDATA(bbt_isNull,1))[((BBUINT)bbt_i)]=0;
				struct database_core_dbtypes_TDBType_obj* bbt_2;
				if(!(((BBObject*)((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)])!= &bbNullObject) || (((bbt_2 = ((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)])->clas)->m_isNull((struct database_core_dbtypes_TDBType_obj*)bbt_2)!=0)){
					((BBINT*)BBARRAYDATA(bbt_isNull,1))[((BBUINT)bbt_i)]=-1;
				}
				struct database_core_dbtypes_TDBType_obj* bbt_4;
				BBINT bbt_3=((bbt_4 = ((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)])->clas)->m_kind((struct database_core_dbtypes_TDBType_obj*)bbt_4);
				if(bbt_3==2){
					if(!(((BBObject*)((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)])!= &bbNullObject)){
						((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)]=(struct database_core_dbtypes_TDBType_obj*)((struct database_core_dbtypes_TDBType_obj*)bbObjectDowncast((BBOBJECT)(struct database_core_dbtypes_TDBInt_obj*)bbObjectAtomicNew((BBClass *)&database_core_dbtypes_TDBInt),(BBClass*)&database_core_dbtypes_TDBType));
					}
					bbt_result=bmx_odbc_SQLBindParameter_int(o->_database_core_tqueryresultset_stmthandle ,(bbt_i+1),(&((struct database_core_dbtypes_TDBInt_obj*)bbObjectDowncast((BBOBJECT)((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)],(BBClass*)&database_core_dbtypes_TDBInt))->_database_core_dbtypes_tdbint_value ),(&((BBINT*)BBARRAYDATA(bbt_isNull,1))[((BBUINT)bbt_i)]));
				}else{
					if(bbt_3==4){
						if(!(((BBObject*)((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)])!= &bbNullObject)){
							((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)]=(struct database_core_dbtypes_TDBType_obj*)((struct database_core_dbtypes_TDBType_obj*)bbObjectDowncast((BBOBJECT)(struct database_core_dbtypes_TDBDouble_obj*)bbObjectAtomicNew((BBClass *)&database_core_dbtypes_TDBDouble),(BBClass*)&database_core_dbtypes_TDBType));
						}
						if(((BBObject*)((struct database_core_dbtypes_TDBFloat_obj*)bbObjectDowncast((BBOBJECT)((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)],(BBClass*)&database_core_dbtypes_TDBFloat)))!= &bbNullObject){
							struct database_core_dbtypes_TDBDouble_obj* bbt_d=(struct database_core_dbtypes_TDBDouble_obj*)(struct database_core_dbtypes_TDBDouble_obj*)bbObjectAtomicNew((BBClass *)&database_core_dbtypes_TDBDouble);
							(bbt_d)->clas->m_setDouble_d((struct database_core_dbtypes_TDBDouble_obj*)bbt_d,((BBDOUBLE)((struct database_core_dbtypes_TDBFloat_obj*)bbObjectDowncast((BBOBJECT)((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)],(BBClass*)&database_core_dbtypes_TDBFloat))->_database_core_dbtypes_tdbfloat_value ));
							struct database_core_dbtypes_TDBType_obj* bbt_5;
							((bbt_5 = ((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)])->clas)->m_clear((struct database_core_dbtypes_TDBType_obj*)bbt_5);
							((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)]=(struct database_core_dbtypes_TDBType_obj*)((struct database_core_dbtypes_TDBType_obj*)bbObjectDowncast((BBOBJECT)bbt_d,(BBClass*)&database_core_dbtypes_TDBType));
						}
						bbt_result=bmx_odbc_SQLBindParameter_double(o->_database_core_tqueryresultset_stmthandle ,(bbt_i+1),(&((struct database_core_dbtypes_TDBDouble_obj*)bbObjectDowncast((BBOBJECT)((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)],(BBClass*)&database_core_dbtypes_TDBDouble))->_database_core_dbtypes_tdbdouble_value ),(&((BBINT*)BBARRAYDATA(bbt_isNull,1))[((BBUINT)bbt_i)]));
					}else{
						if(bbt_3==3){
							if(!(((BBObject*)((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)])!= &bbNullObject)){
								((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)]=(struct database_core_dbtypes_TDBType_obj*)((struct database_core_dbtypes_TDBType_obj*)bbObjectDowncast((BBOBJECT)(struct database_core_dbtypes_TDBDouble_obj*)bbObjectAtomicNew((BBClass *)&database_core_dbtypes_TDBDouble),(BBClass*)&database_core_dbtypes_TDBType));
							}
							bbt_result=bmx_odbc_SQLBindParameter_double(o->_database_core_tqueryresultset_stmthandle ,(bbt_i+1),(&((struct database_core_dbtypes_TDBDouble_obj*)bbObjectDowncast((BBOBJECT)((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)],(BBClass*)&database_core_dbtypes_TDBDouble))->_database_core_dbtypes_tdbdouble_value ),(&((BBINT*)BBARRAYDATA(bbt_isNull,1))[((BBUINT)bbt_i)]));
						}else{
							if(bbt_3==5){
								if(!(((BBObject*)((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)])!= &bbNullObject)){
									((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)]=(struct database_core_dbtypes_TDBType_obj*)((struct database_core_dbtypes_TDBType_obj*)bbObjectDowncast((BBOBJECT)(struct database_core_dbtypes_TDBLong_obj*)bbObjectAtomicNew((BBClass *)&database_core_dbtypes_TDBLong),(BBClass*)&database_core_dbtypes_TDBType));
								}
								bbt_result=bmx_odbc_SQLBindParameter_long(o->_database_core_tqueryresultset_stmthandle ,(bbt_i+1),(&((struct database_core_dbtypes_TDBLong_obj*)bbObjectDowncast((BBOBJECT)((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)],(BBClass*)&database_core_dbtypes_TDBLong))->_database_core_dbtypes_tdblong_value ),(&((BBINT*)BBARRAYDATA(bbt_isNull,1))[((BBUINT)bbt_i)]));
							}else{
								if(bbt_3==1){
									if(!(((BBObject*)((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)])!= &bbNullObject)){
										((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)]=(struct database_core_dbtypes_TDBType_obj*)((struct database_core_dbtypes_TDBType_obj*)bbObjectDowncast((BBOBJECT)(struct database_core_dbtypes_TDBString_obj*)bbObjectNew((BBClass *)&database_core_dbtypes_TDBString),(BBClass*)&database_core_dbtypes_TDBType));
									}
									struct database_core_dbtypes_TDBType_obj* bbt_6;
									BBBYTE* bbt_s=bbStringToUTF8String((BBSTRING)((bbt_6 = ((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)])->clas)->m_getString((struct database_core_dbtypes_TDBType_obj*)bbt_6));
									((BBBYTE**)BBARRAYDATA(bbt_strings,1))[((BBUINT)bbt_i)]=bbt_s;
									BBINT bbt_length=((BBINT)strlen((const char*)bbt_s));
									if(!(((BBINT*)BBARRAYDATA(bbt_isNull,1))[((BBUINT)bbt_i)]!=0)){
										((BBINT*)BBARRAYDATA(bbt_isNull,1))[((BBUINT)bbt_i)]=bbt_length;
									}
									bbt_result=bmx_odbc_SQLBindParameter_string(o->_database_core_tqueryresultset_stmthandle ,(bbt_i+1),bbt_s,bbt_length,(&((BBINT*)BBARRAYDATA(bbt_isNull,1))[((BBUINT)bbt_i)]));
								}else{
									if(bbt_3==7){
									}else{
										if(bbt_3==6){
											if(!(((BBObject*)((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)])!= &bbNullObject)){
												((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)]=(struct database_core_dbtypes_TDBType_obj*)((struct database_core_dbtypes_TDBType_obj*)bbObjectDowncast((BBOBJECT)(struct database_core_dbtypes_TDBDate_obj*)bbObjectAtomicNew((BBClass *)&database_core_dbtypes_TDBDate),(BBClass*)&database_core_dbtypes_TDBType));
											}
											struct database_core_dbtypes_TDBType_obj* bbt_7;
											BBBYTE* bbt_s2=bbStringToUTF8String((BBSTRING)((bbt_7 = ((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)])->clas)->m_getString((struct database_core_dbtypes_TDBType_obj*)bbt_7));
											((BBBYTE**)BBARRAYDATA(bbt_strings,1))[((BBUINT)bbt_i)]=bbt_s2;
											BBINT bbt_length2=((BBINT)strlen((const char*)bbt_s2));
											if(!(((BBINT*)BBARRAYDATA(bbt_isNull,1))[((BBUINT)bbt_i)]!=0)){
												((BBINT*)BBARRAYDATA(bbt_isNull,1))[((BBUINT)bbt_i)]=bbt_length2;
											}
											bbt_result=bmx_odbc_SQLBindParameter_string(o->_database_core_tqueryresultset_stmthandle ,(bbt_i+1),bbt_s2,bbt_length2,(&((BBINT*)BBARRAYDATA(bbt_isNull,1))[((BBUINT)bbt_i)]));
										}else{
											if(bbt_3==8){
												if(!(((BBObject*)((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)])!= &bbNullObject)){
													((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)]=(struct database_core_dbtypes_TDBType_obj*)((struct database_core_dbtypes_TDBType_obj*)bbObjectDowncast((BBOBJECT)(struct database_core_dbtypes_TDBDateTime_obj*)bbObjectAtomicNew((BBClass *)&database_core_dbtypes_TDBDateTime),(BBClass*)&database_core_dbtypes_TDBType));
												}
												struct database_core_dbtypes_TDBType_obj* bbt_8;
												BBBYTE* bbt_s3=bbStringToUTF8String((BBSTRING)((bbt_8 = ((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)])->clas)->m_getString((struct database_core_dbtypes_TDBType_obj*)bbt_8));
												((BBBYTE**)BBARRAYDATA(bbt_strings,1))[((BBUINT)bbt_i)]=bbt_s3;
												BBINT bbt_length3=((BBINT)strlen((const char*)bbt_s3));
												if(!(((BBINT*)BBARRAYDATA(bbt_isNull,1))[((BBUINT)bbt_i)]!=0)){
													((BBINT*)BBARRAYDATA(bbt_isNull,1))[((BBUINT)bbt_i)]=bbt_length3;
												}
												bbt_result=bmx_odbc_SQLBindParameter_string(o->_database_core_tqueryresultset_stmthandle ,(bbt_i+1),bbt_s3,bbt_length3,(&((BBINT*)BBARRAYDATA(bbt_isNull,1))[((BBUINT)bbt_i)]));
											}else{
												if(bbt_3==9){
													if(!(((BBObject*)((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)])!= &bbNullObject)){
														((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)]=(struct database_core_dbtypes_TDBType_obj*)((struct database_core_dbtypes_TDBType_obj*)bbObjectDowncast((BBOBJECT)(struct database_core_dbtypes_TDBTime_obj*)bbObjectAtomicNew((BBClass *)&database_core_dbtypes_TDBTime),(BBClass*)&database_core_dbtypes_TDBType));
													}
													struct database_core_dbtypes_TDBType_obj* bbt_9;
													BBBYTE* bbt_s4=bbStringToUTF8String((BBSTRING)((bbt_9 = ((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(bbt_values,1))[((BBUINT)bbt_i)])->clas)->m_getString((struct database_core_dbtypes_TDBType_obj*)bbt_9));
													((BBBYTE**)BBARRAYDATA(bbt_strings,1))[((BBUINT)bbt_i)]=bbt_s4;
													BBINT bbt_length4=((BBINT)strlen((const char*)bbt_s4));
													if(!(((BBINT*)BBARRAYDATA(bbt_isNull,1))[((BBUINT)bbt_i)]!=0)){
														((BBINT*)BBARRAYDATA(bbt_isNull,1))[((BBUINT)bbt_i)]=bbt_length4;
													}
													bbt_result=bmx_odbc_SQLBindParameter_string(o->_database_core_tqueryresultset_stmthandle ,(bbt_i+1),bbt_s4,bbt_length4,(&((BBINT*)BBARRAYDATA(bbt_isNull,1))[((BBUINT)bbt_i)]));
												}
											}
										}
									}
								}
							}
						}
					}
				}
				if(database_odbc_isSQLError(bbt_result)!=0){
					struct database_odbc_TDBODBC_obj* bbt_10;
					(((struct database_odbc_TDBODBC_obj*)(bbt_10 = ((struct database_odbc_TDBODBC_obj*)bbObjectDowncast((BBOBJECT)o->_database_core_tqueryresultset_conn ,(BBClass*)&database_odbc_TDBODBC))))->clas)->m_processError_iSipb((struct database_odbc_TDBODBC_obj*)bbt_10,3,((BBString*)&_s26),3,o->_database_core_tqueryresultset_stmthandle );
					{
						BBINT bbt_i2=0;
						BBINT bbt_11=bbt_paramCount;
						for(;(bbt_i2<bbt_11);bbt_i2=(bbt_i2+1)){
							if(((BBBYTE**)BBARRAYDATA(bbt_strings,1))[((BBUINT)bbt_i2)]){
								bbMemFree((void*)((BBBYTE**)BBARRAYDATA(bbt_strings,1))[((BBUINT)bbt_i2)]);
							}
						}
					}
					return 0;
				}
			}
		}
	}
	bbt_result=bmx_odbc_executePrepared(o->_database_core_tqueryresultset_stmthandle );
	if(bbt_strings!= &bbEmptyArray){
		{
			BBINT bbt_i3=0;
			BBINT bbt_12=bbt_paramCount;
			for(;(bbt_i3<bbt_12);bbt_i3=(bbt_i3+1)){
				if(((BBBYTE**)BBARRAYDATA(bbt_strings,1))[((BBUINT)bbt_i3)]){
					bbMemFree((void*)((BBBYTE**)BBARRAYDATA(bbt_strings,1))[((BBUINT)bbt_i3)]);
				}
			}
		}
	}
	if(database_odbc_isSQLError(bbt_result)!=0){
		struct database_odbc_TDBODBC_obj* bbt_13;
		(((struct database_odbc_TDBODBC_obj*)(bbt_13 = ((struct database_odbc_TDBODBC_obj*)bbObjectDowncast((BBOBJECT)o->_database_core_tqueryresultset_conn ,(BBClass*)&database_odbc_TDBODBC))))->clas)->m_processError_iSipb((struct database_odbc_TDBODBC_obj*)bbt_13,3,((BBString*)&_s23),3,o->_database_core_tqueryresultset_stmthandle );
		return 0;
	}
	BBINT bbt_fieldCount=0;
	bmx_odbc_SQLNumResultCols(o->_database_core_tqueryresultset_stmthandle ,(&bbt_fieldCount));
	((struct database_odbc_TODBCResultSet_obj*)o)->clas->m_initRecord_i((struct database_odbc_TODBCResultSet_obj*)o,bbt_fieldCount);
	if(bbt_fieldCount!=0){
		BBINT bbt_bufferLength=256;
		BBBYTE bbt_columnName[256]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
		BBINT bbt_nameLength=0;
		BBINT bbt_dataType=0;
		BBINT bbt_columnSize=0;
		BBINT bbt_decimalDigits=0;
		BBINT bbt_nullable=0;
		{
			BBINT bbt_i4=0;
			BBINT bbt_14=bbt_fieldCount;
			for(;(bbt_i4<bbt_14);bbt_i4=(bbt_i4+1)){
				bbt_result=bmx_odbc_SQLDescribeCol(o->_database_core_tqueryresultset_stmthandle ,(bbt_i4+1),(bbt_columnName),bbt_bufferLength,(&bbt_nameLength),(&bbt_dataType),(&bbt_columnSize),(&bbt_decimalDigits),(&bbt_nullable));
				if(database_odbc_isSQLError(bbt_result)!=0){
					struct database_odbc_TDBODBC_obj* bbt_15;
					(((struct database_odbc_TDBODBC_obj*)(bbt_15 = ((struct database_odbc_TDBODBC_obj*)bbObjectDowncast((BBOBJECT)o->_database_core_tqueryresultset_conn ,(BBClass*)&database_odbc_TDBODBC))))->clas)->m_processError_iSipb((struct database_odbc_TDBODBC_obj*)bbt_15,3,((BBString*)&_s24),3,o->_database_core_tqueryresultset_stmthandle );
					return 0;
				}
				struct database_core_TQueryField_obj* bbt_qf=(struct database_core_TQueryField_obj*)database_core_TQueryField_Create_TTQueryField_Si(bbStringFromUTF8Bytes((bbt_columnName),bbt_nameLength),o->clas->f_dbTypeFromNative_i_Sii((&bbEmptyString),bbt_dataType,0));
				if(bbt_columnSize==0){
					bbt_qf->_database_core_tqueryfield_length =-1;
				}else{
					bbt_qf->_database_core_tqueryfield_length =bbt_columnSize;
				}
				if(bbt_decimalDigits==0){
					bbt_qf->_database_core_tqueryfield_precision =-1;
				}else{
					bbt_qf->_database_core_tqueryfield_precision =bbt_decimalDigits;
				}
				if(bbt_nullable==1){
					bbt_qf->_database_core_tqueryfield_nullable =1;
				}else{
					if(bbt_nullable==0){
						bbt_qf->_database_core_tqueryfield_nullable =0;
					}
				}
				(o->_database_core_tqueryresultset_rec )->clas->m_setField_iTTQueryField((struct database_core_TQueryRecord_obj*)o->_database_core_tqueryresultset_rec ,bbt_i4,(struct database_core_TQueryField_obj*)bbt_qf);
			}
		}
	}
	o->_database_core_tqueryresultset__isactive =1;
	return 1;
}
BBINT _database_odbc_TODBCResultSet_firstRow(struct database_odbc_TODBCResultSet_obj* o){
	if(o->_database_core_tqueryresultset_index ==-1){
		return ((struct database_odbc_TODBCResultSet_obj*)o)->clas->m_nextRow((struct database_odbc_TODBCResultSet_obj*)o);
	}
	return 0;
}
BBINT _database_odbc_TODBCResultSet_nextRow(struct database_odbc_TODBCResultSet_obj* o){
	if(!(o->_database_core_tqueryresultset_stmthandle )){
		return 0;
	}
	BBINT bbt_result=bmx_odbc_SQLFetchScroll(o->_database_core_tqueryresultset_stmthandle );
	if((bbt_result!=0) && (bbt_result!=1)){
		if(bbt_result!=100){
			struct database_odbc_TDBODBC_obj* bbt_;
			(((struct database_odbc_TDBODBC_obj*)(bbt_ = ((struct database_odbc_TDBODBC_obj*)bbObjectDowncast((BBOBJECT)o->_database_core_tqueryresultset_conn ,(BBClass*)&database_odbc_TDBODBC))))->clas)->m_processError_iSipb((struct database_odbc_TDBODBC_obj*)bbt_,3,((BBString*)&_s27),3,o->_database_core_tqueryresultset_stmthandle );
		}
		return 0;
	}
	{
		BBINT bbt_i=0;
		BBINT bbt_2=(o->_database_core_tqueryresultset_rec )->clas->m_count((struct database_core_TQueryRecord_obj*)o->_database_core_tqueryresultset_rec );
		for(;(bbt_i<bbt_2);bbt_i=(bbt_i+1)){
			if(((BBObject*)((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(o->_database_core_tqueryresultset_values ,1))[((BBUINT)bbt_i)])!= &bbNullObject){
				struct database_core_dbtypes_TDBType_obj* bbt_3;
				((bbt_3 = ((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(o->_database_core_tqueryresultset_values ,1))[((BBUINT)bbt_i)])->clas)->m_clear((struct database_core_dbtypes_TDBType_obj*)bbt_3);
			}
			BBINT bbt_lenIndicator=0;
			BBINT bbt_4=((struct database_core_TQueryField_obj**)BBARRAYDATA(o->_database_core_tqueryresultset_rec ->_database_core_tqueryrecord_fields ,1))[((BBUINT)bbt_i)]->_database_core_tqueryfield_ftype ;
			if(bbt_4==2){
				BBINT bbt_intValue=0;
				bbt_result=bmx_odbc_SQLGetData_int(o->_database_core_tqueryresultset_stmthandle ,(bbt_i+1),(&bbt_intValue),(&bbt_lenIndicator));
				if((database_odbc_isSQLError(bbt_result)!=0) || (bbt_lenIndicator==-1)){
					continue;
				}
				((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(o->_database_core_tqueryresultset_values ,1))[((BBUINT)bbt_i)]=(struct database_core_dbtypes_TDBType_obj*)((struct database_core_dbtypes_TDBType_obj*)bbObjectDowncast((BBOBJECT)(struct database_core_dbtypes_TDBInt_obj*)bbObjectAtomicNew((BBClass *)&database_core_dbtypes_TDBInt),(BBClass*)&database_core_dbtypes_TDBType));
				struct database_core_dbtypes_TDBType_obj* bbt_5;
				((bbt_5 = ((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(o->_database_core_tqueryresultset_values ,1))[((BBUINT)bbt_i)])->clas)->m_setInt_i((struct database_core_dbtypes_TDBType_obj*)bbt_5,bbt_intValue);
			}else{
				if(bbt_4==5){
					BBLONG bbt_longValue=0LL;
					bbt_result=bmx_odbc_SQLGetData_long(o->_database_core_tqueryresultset_stmthandle ,(bbt_i+1),(&bbt_longValue),(&bbt_lenIndicator));
					if((database_odbc_isSQLError(bbt_result)!=0) || (bbt_lenIndicator==-1)){
						continue;
					}
					((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(o->_database_core_tqueryresultset_values ,1))[((BBUINT)bbt_i)]=(struct database_core_dbtypes_TDBType_obj*)((struct database_core_dbtypes_TDBType_obj*)bbObjectDowncast((BBOBJECT)(struct database_core_dbtypes_TDBLong_obj*)bbObjectAtomicNew((BBClass *)&database_core_dbtypes_TDBLong),(BBClass*)&database_core_dbtypes_TDBType));
					struct database_core_dbtypes_TDBType_obj* bbt_6;
					((bbt_6 = ((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(o->_database_core_tqueryresultset_values ,1))[((BBUINT)bbt_i)])->clas)->m_setLong_l((struct database_core_dbtypes_TDBType_obj*)bbt_6,bbt_longValue);
				}else{
					if(bbt_4==3){
						BBDOUBLE bbt_doubleValue=.0000000000000000;
						bbt_result=bmx_odbc_SQLGetData_double(o->_database_core_tqueryresultset_stmthandle ,(bbt_i+1),(&bbt_doubleValue),(&bbt_lenIndicator));
						if((database_odbc_isSQLError(bbt_result)!=0) || (bbt_lenIndicator==-1)){
							continue;
						}
						((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(o->_database_core_tqueryresultset_values ,1))[((BBUINT)bbt_i)]=(struct database_core_dbtypes_TDBType_obj*)((struct database_core_dbtypes_TDBType_obj*)bbObjectDowncast((BBOBJECT)(struct database_core_dbtypes_TDBDouble_obj*)bbObjectAtomicNew((BBClass *)&database_core_dbtypes_TDBDouble),(BBClass*)&database_core_dbtypes_TDBType));
						struct database_core_dbtypes_TDBType_obj* bbt_7;
						((bbt_7 = ((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(o->_database_core_tqueryresultset_values ,1))[((BBUINT)bbt_i)])->clas)->m_setDouble_d((struct database_core_dbtypes_TDBType_obj*)bbt_7,bbt_doubleValue);
					}else{
						if(bbt_4==6){
							BBINT bbt_y=0;
							BBINT bbt_m=0;
							BBINT bbt_d=0;
							bbt_result=bmx_odbc_SQLGetData_date(o->_database_core_tqueryresultset_stmthandle ,(bbt_i+1),(&bbt_y),(&bbt_m),(&bbt_d),(&bbt_lenIndicator));
							if((database_odbc_isSQLError(bbt_result)!=0) || (bbt_lenIndicator==-1)){
								continue;
							}
							struct database_core_dbtypes_TDBDate_obj* bbt_date=(struct database_core_dbtypes_TDBDate_obj*)(struct database_core_dbtypes_TDBDate_obj*)bbObjectAtomicNew((BBClass *)&database_core_dbtypes_TDBDate);
							((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(o->_database_core_tqueryresultset_values ,1))[((BBUINT)bbt_i)]=(struct database_core_dbtypes_TDBType_obj*)((struct database_core_dbtypes_TDBType_obj*)bbObjectDowncast((BBOBJECT)bbt_date,(BBClass*)&database_core_dbtypes_TDBType));
							(bbt_date)->clas->m_setFromParts_iii((struct database_core_dbtypes_TDBDate_obj*)bbt_date,bbt_y,bbt_m,bbt_d);
						}else{
							if(bbt_4==8){
								BBINT bbt_y2=0;
								BBINT bbt_m2=0;
								BBINT bbt_d2=0;
								BBINT bbt_hh=0;
								BBINT bbt_mm=0;
								BBINT bbt_ss=0;
								bbt_result=bmx_odbc_SQLGetData_datetime(o->_database_core_tqueryresultset_stmthandle ,(bbt_i+1),(&bbt_y2),(&bbt_m2),(&bbt_d2),(&bbt_hh),(&bbt_mm),(&bbt_ss),(&bbt_lenIndicator));
								if((database_odbc_isSQLError(bbt_result)!=0) || (bbt_lenIndicator==-1)){
									continue;
								}
								struct database_core_dbtypes_TDBDateTime_obj* bbt_date2=(struct database_core_dbtypes_TDBDateTime_obj*)(struct database_core_dbtypes_TDBDateTime_obj*)bbObjectAtomicNew((BBClass *)&database_core_dbtypes_TDBDateTime);
								((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(o->_database_core_tqueryresultset_values ,1))[((BBUINT)bbt_i)]=(struct database_core_dbtypes_TDBType_obj*)((struct database_core_dbtypes_TDBType_obj*)bbObjectDowncast((BBOBJECT)bbt_date2,(BBClass*)&database_core_dbtypes_TDBType));
								(bbt_date2)->clas->m_setFromParts_iiiiii((struct database_core_dbtypes_TDBDateTime_obj*)bbt_date2,bbt_y2,bbt_m2,bbt_d2,bbt_hh,bbt_mm,bbt_ss);
							}else{
								if(bbt_4==9){
									BBINT bbt_hh2=0;
									BBINT bbt_mm2=0;
									BBINT bbt_ss2=0;
									bbt_result=bmx_odbc_SQLGetData_time(o->_database_core_tqueryresultset_stmthandle ,(bbt_i+1),(&bbt_hh2),(&bbt_mm2),(&bbt_ss2),(&bbt_lenIndicator));
									if((database_odbc_isSQLError(bbt_result)!=0) || (bbt_lenIndicator==-1)){
										continue;
									}
									struct database_core_dbtypes_TDBTime_obj* bbt_date3=(struct database_core_dbtypes_TDBTime_obj*)(struct database_core_dbtypes_TDBTime_obj*)bbObjectAtomicNew((BBClass *)&database_core_dbtypes_TDBTime);
									((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(o->_database_core_tqueryresultset_values ,1))[((BBUINT)bbt_i)]=(struct database_core_dbtypes_TDBType_obj*)((struct database_core_dbtypes_TDBType_obj*)bbObjectDowncast((BBOBJECT)bbt_date3,(BBClass*)&database_core_dbtypes_TDBType));
									(bbt_date3)->clas->m_setFromParts_iii((struct database_core_dbtypes_TDBTime_obj*)bbt_date3,bbt_hh2,bbt_mm2,bbt_ss2);
								}else{
									if(bbt_4==7){
									}else{
										BBSTRING bbt_s=((struct database_odbc_TODBCResultSet_obj*)o)->clas->m_getStringData_TTQueryFieldivi((struct database_odbc_TODBCResultSet_obj*)o,(struct database_core_TQueryField_obj*)((struct database_core_TQueryField_obj**)BBARRAYDATA(o->_database_core_tqueryresultset_rec ->_database_core_tqueryrecord_fields ,1))[((BBUINT)bbt_i)],bbt_i,(&bbt_result));
										if((database_odbc_isSQLError(bbt_result)!=0) || (bbt_result==100)){
											continue;
										}
										if(bbt_s!= &bbEmptyString){
											((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(o->_database_core_tqueryresultset_values ,1))[((BBUINT)bbt_i)]=(struct database_core_dbtypes_TDBType_obj*)((struct database_core_dbtypes_TDBType_obj*)bbObjectDowncast((BBOBJECT)(struct database_core_dbtypes_TDBString_obj*)bbObjectNew((BBClass *)&database_core_dbtypes_TDBString),(BBClass*)&database_core_dbtypes_TDBType));
											struct database_core_dbtypes_TDBType_obj* bbt_8;
											((bbt_8 = ((struct database_core_dbtypes_TDBType_obj**)BBARRAYDATA(o->_database_core_tqueryresultset_values ,1))[((BBUINT)bbt_i)])->clas)->m_setString_S((struct database_core_dbtypes_TDBType_obj*)bbt_8,bbt_s);
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	o->_database_core_tqueryresultset_index +=1;
	return 1;
}
BBSTRING _database_odbc_TODBCResultSet_getStringData_TTQueryFieldivi(struct database_odbc_TODBCResultSet_obj* o,struct database_core_TQueryField_obj* bbt_record,BBINT bbt_i,BBINT* bbt_result){
	struct brl_stringbuilder_TStringBuilder_obj* bbt_sb=(struct brl_stringbuilder_TStringBuilder_obj*)(struct brl_stringbuilder_TStringBuilder_obj*)bbObjectNew((BBClass *)&brl_stringbuilder_TStringBuilder);
	BBINT bbt_bufferSize=bbt_record->_database_core_tqueryfield_length ;
	if(bbt_record->_database_core_tqueryfield_length <=0){
		bbt_bufferSize=256;
	}else{
		if(bbt_record->_database_core_tqueryfield_length >65536){
			bbt_bufferSize=65536;
		}else{
			bbt_bufferSize+=1;
		}
	}
	BBINT bbt_lenIndicator=0;
	BBBYTE* bbt_buffer=bbMemAlloc((size_t)((BBSIZET)bbt_bufferSize));
	BBSTRING bbt_s=((BBString*)&bbEmptyString);
	while(1){
		*bbt_result=bmx_odbc_SQLGetData_string(o->_database_core_tqueryresultset_stmthandle ,(bbt_i+1),bbt_buffer,bbt_bufferSize,(&bbt_lenIndicator));
		if((database_odbc_isSQLError(*bbt_result)!=0) || (*bbt_result==100)){
			break;
		}
		if((bbt_lenIndicator==-1) || (bbt_lenIndicator==-4)){
			break;
		}
		BBINT bbt_actualSize=0;
		if(*bbt_result==1){
			bbt_actualSize=bbt_bufferSize;
		}else{
			bbt_actualSize=bbt_lenIndicator;
		}
		(bbt_sb)->clas->m_AppendUTF8Bytes_pbi((struct brl_stringbuilder_TStringBuilder_obj*)bbt_sb,bbt_buffer,bbt_actualSize);
		if(bbt_lenIndicator<bbt_bufferSize){
			break;
		}
	}
	bbMemFree((void*)bbt_buffer);
	return (bbt_sb)->clas->ToString((struct brl_stringbuilder_TStringBuilder_obj*)bbt_sb);
}
BBLONG _database_odbc_TODBCResultSet_lastInsertedId(struct database_odbc_TODBCResultSet_obj* o){
	return 0LL;
}
BBINT _database_odbc_TODBCResultSet_rowsAffected(struct database_odbc_TODBCResultSet_obj* o){
	if(o->_database_core_tqueryresultset_stmthandle ){
		BBINT bbt_num=0;
		BBINT bbt_result=bmx_odbc_SQLRowCount(o->_database_core_tqueryresultset_stmthandle ,(&bbt_num));
		if(!(database_odbc_isSQLError(bbt_result)!=0)){
			return bbt_num;
		}
	}
	return -1;
}
BBINT database_odbc_TODBCResultSet_dbTypeFromNative_i_Sii(BBSTRING bbt_name,BBINT bbt__type,BBINT bbt__flags){
	BBINT bbt_dbType=0;
	BBINT bbt_=bbt__type;
	if((((bbt_==5) || (bbt_==4)) || (bbt_==-7)) || (bbt_==-6)){
		bbt_dbType=2;
	}else{
		if((bbt_==-5) || (bbt_==65531)){
			bbt_dbType=5;
		}else{
			if(((((bbt_==3) || (bbt_==2)) || (bbt_==7)) || (bbt_==6)) || (bbt_==8)){
				bbt_dbType=3;
			}else{
				if((bbt_==9) || (bbt_==91)){
					bbt_dbType=6;
				}else{
					if((bbt_==10) || (bbt_==92)){
						bbt_dbType=9;
					}else{
						if((bbt_==11) || (bbt_==93)){
							bbt_dbType=8;
						}else{
							if(((bbt_==-2) || (bbt_==-3)) || (bbt_==-4)){
								bbt_dbType=7;
							}else{
								bbt_dbType=1;
							}
						}
					}
				}
			}
		}
	}
	return bbt_dbType;
}
void _database_odbc_TODBCResultSet_initRecord_i(struct database_odbc_TODBCResultSet_obj* o,BBINT bbt_size){
	(o->_database_core_tqueryresultset_rec )->clas->m_clear((struct database_core_TQueryRecord_obj*)o->_database_core_tqueryresultset_rec );
	if(bbt_size>0){
		(o->_database_core_tqueryresultset_rec )->clas->m_Init_i((struct database_core_TQueryRecord_obj*)o->_database_core_tqueryresultset_rec ,bbt_size);
	}
	((struct database_core_TQueryResultSet_obj*)o)->clas->m_resetValues_i((struct database_core_TQueryResultSet_obj*)o,bbt_size);
}
struct BBDebugScope_12 database_odbc_TODBCResultSet_scope ={
	BBDEBUGSCOPE_USERTYPE,
	"TODBCResultSet",
	{
		{
			BBDEBUGDECL_TYPEMETHOD,
			"New",
			"()",
			.func_ptr=(BBFuncPtr)&_database_odbc_TODBCResultSet_New
		},
		{
			BBDEBUGDECL_TYPEFUNCTION,
			"Create",
			"(:TDBConnection,$):TQueryResultSet",
			.func_ptr=(BBFuncPtr)&database_odbc_TODBCResultSet_Create_TTQueryResultSet_TTDBConnectionS
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"executeQuery",
			"($)i",
			.func_ptr=(BBFuncPtr)&_database_odbc_TODBCResultSet_executeQuery_S
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"prepare",
			"($)i",
			.func_ptr=(BBFuncPtr)&_database_odbc_TODBCResultSet_prepare_S
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"execute",
			"()i",
			.func_ptr=(BBFuncPtr)&_database_odbc_TODBCResultSet_execute
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"firstRow",
			"()i",
			.func_ptr=(BBFuncPtr)&_database_odbc_TODBCResultSet_firstRow
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"nextRow",
			"()i",
			.func_ptr=(BBFuncPtr)&_database_odbc_TODBCResultSet_nextRow
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"getStringData",
			"(:TQueryField,i,i)$",
			.func_ptr=(BBFuncPtr)&_database_odbc_TODBCResultSet_getStringData_TTQueryFieldivi
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"lastInsertedId",
			"()l",
			.func_ptr=(BBFuncPtr)&_database_odbc_TODBCResultSet_lastInsertedId
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"rowsAffected",
			"()i",
			.func_ptr=(BBFuncPtr)&_database_odbc_TODBCResultSet_rowsAffected
		},
		{
			BBDEBUGDECL_TYPEFUNCTION,
			"dbTypeFromNative",
			"($,i,i)i",
			.func_ptr=(BBFuncPtr)&database_odbc_TODBCResultSet_dbTypeFromNative_i_Sii
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"initRecord",
			"(i)",
			.func_ptr=(BBFuncPtr)&_database_odbc_TODBCResultSet_initRecord_i
		},
		{
			BBDEBUGDECL_END
		}
	}
};
struct BBClass_database_odbc_TODBCResultSet database_odbc_TODBCResultSet={
	&database_core_TQueryResultSet,
	bbObjectFree,
	(BBDebugScope*)&database_odbc_TODBCResultSet_scope,
	sizeof(struct database_odbc_TODBCResultSet_obj),
	(void (*)(BBOBJECT))_database_odbc_TODBCResultSet_New,
	(void (*)(BBOBJECT))_database_odbc_TODBCResultSet_Delete,
	bbObjectToString,
	bbObjectCompare,
	bbObjectSendMessage,
	0,
	0,
	0
	,0
	,sizeof(void*)
	,database_odbc_TODBCResultSet_Create_TTQueryResultSet_TTDBConnectionS
	,_database_core_TQueryResultSet_Init_TTDBConnectionS
	,_database_core_TQueryResultSet_clearBindValues
	,_database_core_TQueryResultSet_clear
	,_database_odbc_TODBCResultSet_executeQuery_S
	,_database_odbc_TODBCResultSet_prepare_S
	,_database_odbc_TODBCResultSet_execute
	,_database_odbc_TODBCResultSet_firstRow
	,_database_odbc_TODBCResultSet_nextRow
	,_database_odbc_TODBCResultSet_lastInsertedId
	,_database_odbc_TODBCResultSet_rowsAffected
	,database_odbc_TODBCResultSet_dbTypeFromNative_i_Sii
	,_database_core_TQueryResultSet_rowRecord
	,_database_core_TQueryResultSet_dataValue_i
	,_database_core_TQueryResultSet_rowIndex
	,_database_core_TQueryResultSet_setRowIndex_i
	,_database_core_TQueryResultSet_isActive
	,_database_core_TQueryResultSet_isValid
	,_database_core_TQueryResultSet_resetValues_i
	,_database_core_TQueryResultSet_resetBindCount
	,_database_core_TQueryResultSet_addBindValue_TTDBType
	,_database_core_TQueryResultSet_bindValue_iTTDBType
	,_database_core_TQueryResultSet_reset
	,_database_core_TQueryResultSet_free
	,_database_odbc_TODBCResultSet_getStringData_TTQueryFieldivi
	,_database_odbc_TODBCResultSet_initRecord_i
};

BBINT database_odbc_isSQLError(BBINT bbt_result){
	if((bbt_result==0) || (bbt_result==1)){
		return 0;
	}
	return 1;
}
static int __bb_database_odbc_odbc_inited = 0;
int __bb_database_odbc_odbc(){
	if (!__bb_database_odbc_odbc_inited) {
		__bb_database_odbc_odbc_inited = 1;
		__bb_brl_blitz_blitz();
		__bb_database_core_core();
		__bb_brl_stringbuilder_stringbuilder();
		__bb_pub_stdc_stdc();
		_bb_database_odbc_common();
		bbObjectRegisterType((BBCLASS)&database_odbc_TODBCDatabaseLoader);
		bbObjectRegisterType((BBCLASS)&database_odbc_TDBODBC);
		bbObjectRegisterType((BBCLASS)&database_odbc_TODBCResultSet);
		database_core_AddDatabaseLoader((struct database_core_TDatabaseLoader_obj*)((struct database_core_TDatabaseLoader_obj*)bbObjectDowncast((BBOBJECT)(struct database_odbc_TODBCDatabaseLoader_obj*)bbObjectNew((BBClass *)&database_odbc_TODBCDatabaseLoader),(BBClass*)&database_core_TDatabaseLoader)));
		return 0;
	}
	return 0;
}