sqldata/sqlociapi.cpp
// Get a list of columns for specified index
Get a list of columns for specified index
Get a list of columns for specified index
int SqlOciApi::GetIndexColumns(SqlIndexes &idx, std::list<std::string> &idx_cols, std::list<std::string> &idx_sorts)
{
	int c = 0;
	for(std::list<SqlIndColumns>::iterator i = _table_ind_columns.begin(); i != _table_ind_columns.end(); i++)
	{
		if((*i).schema != NULL && strcmp((*i).schema, idx.schema) == 0 &&
			(*i).index != NULL && strcmp((*i).index, idx.index) == 0)
		{
			std::string column;
			std::string sort;
			if((*i).asc == false && strncmp((*i).column, "SYS_NC0", 7) == 0)
			{
				int p = 0;
				for(std::list<SqlIndExp>::iterator k = _table_ind_expressions.begin(); k != _table_ind_expressions.end(); k++)
				{
					if((*k).schema != NULL && strcmp((*k).schema, idx.schema) == 0 &&
						(*k).index != NULL && strcmp((*k).index, idx.index) == 0)
					{
						if(p != c)
						{
							p++; 
							continue;
						}
						char *cur = (*k).expression;
						if(cur && *cur == '"')
						{
							cur++;
							while(*cur != '"') { column += *cur; cur++; }
						}
						break;
					}
				}
			}
			else
				column = (*i).column;
			if((*i).asc == false)
				sort = "DESC";
			idx_cols.push_back(column);
			idx_sorts.push_back(sort);
			c++;
		}
		else
		if(c > 0)
			break;
	}
	return 0;
}
int SqlOciApi :: GetIndexColumns ( SqlIndexes & idx , std :: list < std :: string > & idx_cols , std :: list < std :: string > & idx_sorts ) { int c = 0 ; for ( std :: list < SqlIndColumns > :: iterator i = _table_ind_columns . begin ( ) ; i != _table_ind_columns . end ( ) ; i ++ ) { if ( ( * i ) . schema != NULL && strcmp ( ( * i ) . schema , idx . schema ) == 0 && ( * i ) . index != NULL && strcmp ( ( * i ) . index , idx . index ) == 0 ) { std :: string column ; std :: string sort ; if ( ( * i ) . asc == false && strncmp ( ( * i ) . column , " " , 7 ) == 0 ) { int p = 0 ; for ( std :: list < SqlIndExp > :: iterator k = _table_ind_expressions . begin ( ) ; k != _table_ind_expressions . end ( ) ; k ++ ) { if ( ( * k ) . schema != NULL && strcmp ( ( * k ) . schema , idx . schema ) == 0 && ( * k ) . index != NULL && strcmp ( ( * k ) . index , idx . index ) == 0 ) { if ( p != c ) { p ++ ; continue ; } char * cur = ( * k ) . expression ; if ( cur && * cur == ' ' ) { cur ++ ; while ( * cur != ' ' ) { column += * cur ; cur ++ ; } } break ; } } } else column = ( * i ) . column ; if ( ( * i ) . asc == false ) sort = " " ; idx_cols . push_back ( column ) ; idx_sorts . push_back ( sort ) ; c ++ ; } else if ( c > 0 ) break ; } return 0 ; }
Get a list of columns for specified index
Get a list of columns for specified index
// Find index columns // Compare schema and index names (columns are already ordered) // For DESC columns Oracle uses an expression, find the real column name // Find the expression with the same position // Column name is enclosed with quotes, remove them // Index columns ended