sqldata/sqlociapi.cpp
// Get a list of columns for specified primary or unique key
Get a list of columns for specified primary or unique key
Get a list of columns for specified primary or unique key
int SqlOciApi::GetKeyConstraintColumns(SqlConstraints &cns, std::list<std::string> &output, std::list<std::string> *types)
{
	bool found = false;
	if(cns.schema == NULL || cns.table == NULL || cns.constraint == NULL)
		return -1;
	for(std::list<SqlConsColumns>::iterator i = _table_cons_columns.begin(); i != _table_cons_columns.end(); i++)
	{
		char *s = (*i).schema;
		char *t = (*i).table;
		char *c = (*i).constraint;
		char *col = (*i).column;
		if(s == NULL || t == NULL || c == NULL || col == NULL)
			continue;
		if(strcmp(cns.constraint, c) == 0 && strcmp(cns.table, t) == 0 && strcmp(cns.schema, s) == 0)
		{
			output.push_back(col);
			found = true;
			if(types != NULL)
			{
				for(std::list<SqlColMeta>::iterator m = _table_columns.begin(); m != _table_columns.end(); m++)
				{
					char *cs = (*m).schema;
					char *ct = (*m).table;
					char *ccol = (*m).column;
					char *dt = (*m).data_type;
					if(cs == NULL || ct == NULL || ccol == NULL || dt == NULL)
						break;
					if(strcmp(cs, s) == 0 && strcmp(ct, t) == 0 && strcmp(ccol, col) == 0)
					{
						if(!_stricmp(dt, "CHAR") || !_stricmp(dt, "VARCHAR2") || !_stricmp(dt, "VARCHAR"))
							types->push_back("String");
						else
							types->push_back(dt);
						break;
					}
				}
			}
		}
		else
		if(found)
			break;
	}
	return 0;
}
int SqlOciApi :: GetKeyConstraintColumns ( SqlConstraints & cns , std :: list < std :: string > & output , std :: list < std :: string > * types ) { bool found = false ; if ( cns . schema == NULL || cns . table == NULL || cns . constraint == NULL ) return -1 ; for ( std :: list < SqlConsColumns > :: iterator i = _table_cons_columns . begin ( ) ; i != _table_cons_columns . end ( ) ; i ++ ) { char * s = ( * i ) . schema ; char * t = ( * i ) . table ; char * c = ( * i ) . constraint ; char * col = ( * i ) . column ; if ( s == NULL || t == NULL || c == NULL || col == NULL ) continue ; if ( strcmp ( cns . constraint , c ) == 0 && strcmp ( cns . table , t ) == 0 && strcmp ( cns . schema , s ) == 0 ) { output . push_back ( col ) ; found = true ; if ( types != NULL ) { for ( std :: list < SqlColMeta > :: iterator m = _table_columns . begin ( ) ; m != _table_columns . end ( ) ; m ++ ) { char * cs = ( * m ) . schema ; char * ct = ( * m ) . table ; char * ccol = ( * m ) . column ; char * dt = ( * m ) . data_type ; if ( cs == NULL || ct == NULL || ccol == NULL || dt == NULL ) break ; if ( strcmp ( cs , s ) == 0 && strcmp ( ct , t ) == 0 && strcmp ( ccol , col ) == 0 ) { if ( ! _stricmp ( dt , " " ) || ! _stricmp ( dt , " " ) || ! _stricmp ( dt , " " ) ) types -> push_back ( " " ) ; else types -> push_back ( dt ) ; break ; } } } } else if ( found ) break ; } return 0 ; }
Get a list of columns for specified primary or unique key
Get a list of columns for specified primary or unique key
// Compare schema, table and constraint names (columns are already ordered) // Find data type