sqldata/sqldb.cpp
// Get column data from the buffer
Get column data from the buffer
Get column data from the buffer
int SqlDb::GetColumnData(SqlCol *cols, int row, int column, int db_type, SqlApiBase *db_api, 
							char **str, bool *int_set, int *int_value, SQL_TIMESTAMP_STRUCT **ts_struct, 
							char **ora_date)
{
	if(cols == NULL || db_api == NULL)
		return -1;
	char *s = NULL;
	char *ora_d = NULL;
	int int_v = 0;
	bool int_s = false;
	SQL_TIMESTAMP_STRUCT *ts = NULL;
	if(db_type == SQLDATA_ORACLE)
	{
		if(cols[column]._native_fetch_dt == SQLT_STR || cols[column]._native_fetch_dt == SQLT_BIN)
			s = cols[column]._data + cols[column]._fetch_len * row;
		else
		if(cols[column]._native_fetch_dt == SQLT_INT)
		{
			int_v = *((int*)(cols[column]._data + cols[column]._fetch_len * row));
			int_s = true;
		}
		else
		if(cols[column]._native_fetch_dt == SQLT_DAT)
			ora_d = cols[column]._data + cols[column]._fetch_len * row;
	}
	else
	if(db_type == SQLDATA_SYBASE)
	{ 
		if(cols[column]._native_fetch_dt == CS_CHAR_TYPE) 
			s = cols[column]._data + cols[column]._fetch_len * row;
	}
	else
	if(db_type == SQLDATA_MYSQL)
	{
		s = cols[column]._data + cols[column]._fetch_len * row;
	}
	else
	if(db_type == SQLDATA_POSTGRESQL)
	{
		s = cols[column]._data + cols[column]._fetch_len * row;
	}
	else
	if(db_type == SQLDATA_SQL_SERVER || db_type == SQLDATA_INFORMIX)
	{
		if(cols[column]._native_fetch_dt == SQL_C_CHAR || cols[column]._native_fetch_dt == SQL_C_BINARY)
			s = cols[column]._data + cols[column]._fetch_len * row;
		else
		if(cols[column]._native_fetch_dt == SQL_C_LONG)
		{
			int_v = *((int*)(cols[column]._data + cols[column]._fetch_len * row));
			int_s = true;
		}
		else
		if(cols[column]._native_fetch_dt == SQL_TYPE_TIMESTAMP)
			ts = (SQL_TIMESTAMP_STRUCT*)(cols[column]._data + cols[column]._fetch_len * row);
	}
	if(str != NULL && s != NULL)
		*str = s;
	if(int_value != NULL && int_set != NULL && int_s == true)
	{
		*int_value = int_v;
		*int_set = true;
	}
	if(ts_struct != NULL && ts != NULL)
		*ts_struct = ts;
	if(ora_date != NULL && ora_d != NULL)
		*ora_date = ora_d;
	return 0;
}
int SqlDb :: GetColumnData ( SqlCol * cols , int row , int column , int db_type , SqlApiBase * db_api , char * * str , bool * int_set , int * int_value , SQL_TIMESTAMP_STRUCT * * ts_struct , char * * ora_date ) { if ( cols == NULL || db_api == NULL ) return -1 ; char * s = NULL ; char * ora_d = NULL ; int int_v = 0 ; bool int_s = false ; SQL_TIMESTAMP_STRUCT * ts = NULL ; if ( db_type == SQLDATA_ORACLE ) { if ( cols [ column ] . _native_fetch_dt == SQLT_STR || cols [ column ] . _native_fetch_dt == SQLT_BIN ) s = cols [ column ] . _data + cols [ column ] . _fetch_len * row ; else if ( cols [ column ] . _native_fetch_dt == SQLT_INT ) { int_v = * ( ( int * ) ( cols [ column ] . _data + cols [ column ] . _fetch_len * row ) ) ; int_s = true ; } else if ( cols [ column ] . _native_fetch_dt == SQLT_DAT ) ora_d = cols [ column ] . _data + cols [ column ] . _fetch_len * row ; } else if ( db_type == SQLDATA_SYBASE ) { if ( cols [ column ] . _native_fetch_dt == CS_CHAR_TYPE ) s = cols [ column ] . _data + cols [ column ] . _fetch_len * row ; } else if ( db_type == SQLDATA_MYSQL ) { s = cols [ column ] . _data + cols [ column ] . _fetch_len * row ; } else if ( db_type == SQLDATA_POSTGRESQL ) { s = cols [ column ] . _data + cols [ column ] . _fetch_len * row ; } else if ( db_type == SQLDATA_SQL_SERVER || db_type == SQLDATA_INFORMIX ) { if ( cols [ column ] . _native_fetch_dt == SQL_C_CHAR || cols [ column ] . _native_fetch_dt == SQL_C_BINARY ) s = cols [ column ] . _data + cols [ column ] . _fetch_len * row ; else if ( cols [ column ] . _native_fetch_dt == SQL_C_LONG ) { int_v = * ( ( int * ) ( cols [ column ] . _data + cols [ column ] . _fetch_len * row ) ) ; int_s = true ; } else if ( cols [ column ] . _native_fetch_dt == SQL_TYPE_TIMESTAMP ) ts = ( SQL_TIMESTAMP_STRUCT * ) ( cols [ column ] . _data + cols [ column ] . _fetch_len * row ) ; } if ( str != NULL && s != NULL ) * str = s ; if ( int_value != NULL && int_set != NULL && int_s == true ) { * int_value = int_v ; * int_set = true ; } if ( ts_struct != NULL && ts != NULL ) * ts_struct = ts ; if ( ora_date != NULL && ora_d != NULL ) * ora_date = ora_d ; return 0 ; }
Get column data from the buffer
Get column data from the buffer
// All columns are fetched as strings