sqldata/sqldb.cpp
// Check if a column belongs to primary key
Check if a column belongs to primary key
Check if a column belongs to primary key
bool SqlDb::IsPrimaryKeyColumn(const char *s_table, const char *column)
{
    if(s_table == NULL || column == NULL)
        return false;
	std::list<SqlColMeta> *table_columns = _metaSqlDb->GetTableColumns(SQLDB_SOURCE_ONLY);
	if(table_columns == NULL)
		return 0;
	std::string schema;
	std::string table;
	SqlApiBase::SplitQualifiedName(s_table, schema, table);
	for(std::list<SqlColMeta>::iterator i = table_columns->begin(); i != table_columns->end(); i++)
	{
        if((*i).pk_column == false)
			continue;
		char *col = (*i).column;
		char *tab = (*i).table;
		char *sch = (*i).schema;
		if(col == NULL || tab == NULL || sch == NULL)
			continue;
		if(_stricmp(col, column) == 0 && _stricmp(tab, table.c_str()) == 0 &&
			_stricmp(sch, schema.c_str()) == 0)
            return (*i).pk_column;
	}
    return false;
}
bool SqlDb :: IsPrimaryKeyColumn ( const char * s_table , const char * column ) { if ( s_table == NULL || column == NULL ) return false ; std :: list < SqlColMeta > * table_columns = _metaSqlDb -> GetTableColumns ( SQLDB_SOURCE_ONLY ) ; if ( table_columns == NULL ) return 0 ; std :: string schema ; std :: string table ; SqlApiBase :: SplitQualifiedName ( s_table , schema , table ) ; for ( std :: list < SqlColMeta > :: iterator i = table_columns -> begin ( ) ; i != table_columns -> end ( ) ; i ++ ) { if ( ( * i ) . pk_column == false ) continue ; char * col = ( * i ) . column ; char * tab = ( * i ) . table ; char * sch = ( * i ) . schema ; if ( col == NULL || tab == NULL || sch == NULL ) continue ; if ( _stricmp ( col , column ) == 0 && _stricmp ( tab , table . c_str ( ) ) == 0 && _stricmp ( sch , schema . c_str ( ) ) == 0 ) return ( * i ) . pk_column ; } return false ; }
Check if a column belongs to primary key
Check if a column belongs to primary key
// Find mapping record for this table and column // Not a primary key column