Skip to content

Commit 45fc5ff

Browse files
authored
Merge pull request #12 from RoelantVos/Development-branch---v1.5.2
Fix Attribute Mapping BUG for HSTG views
2 parents 0f2bff2 + 01e1662 commit 45fc5ff

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

TEAM/Form_Manage_Metadata.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1890,6 +1890,7 @@ private void backgroundWorker_DoWorkMetadataActivation(object sender, DoWorkEven
18901890

18911891
// Get everything as local variables to reduce multithreading issues
18921892
var stagingDatabase = '[' + configurationSettings.StagingDatabaseName + ']';
1893+
var psaDatabase = '[' + configurationSettings.PsaDatabaseName+ ']';
18931894
var integrationDatabase = '['+ configurationSettings.IntegrationDatabaseName + ']';
18941895

18951896
var linkedServer = configurationSettings.LinkedServer;
@@ -3140,7 +3141,16 @@ private void backgroundWorker_DoWorkMetadataActivation(object sender, DoWorkEven
31403141
prepareMappingStatement.AppendLine(" stg_attr.ATTRIBUTE_NAME AS ATTRIBUTE_TO_NAME,");
31413142
prepareMappingStatement.AppendLine(" 'N' as MULTI_ACTIVE_KEY_INDICATOR,");
31423143
prepareMappingStatement.AppendLine(" 'automatically_mapped' AS VERIFICATION");
3143-
prepareMappingStatement.AppendLine("FROM " + linkedServer + stagingDatabase + ".INFORMATION_SCHEMA.COLUMNS mapping");
3144+
//prepareMappingStatement.AppendLine("FROM " + linkedServer + stagingDatabase + ".INFORMATION_SCHEMA.COLUMNS mapping");
3145+
/*LBM 17-04-2018 - Temporary fix to allow mapping when the View comes from a HSTG*/
3146+
prepareMappingStatement.AppendLine(" FROM (");
3147+
prepareMappingStatement.AppendLine(" SELECT COALESCE(A.TABLE_NAME,SUBSTRING (B.TABLE_NAME,2,LEN(B.TABLE_NAME))) TABLE_NAME, COALESCE(A.COLUMN_NAME, B.COLUMN_NAME) COLUMN_NAME");
3148+
prepareMappingStatement.AppendLine(" FROM " + linkedServer + stagingDatabase + ".INFORMATION_SCHEMA.COLUMNS A");
3149+
prepareMappingStatement.AppendLine(" FULL OUTER JOIN " + linkedServer + psaDatabase + ".INFORMATION_SCHEMA.COLUMNS B");
3150+
prepareMappingStatement.AppendLine(" ON A.TABLE_NAME = SUBSTRING (B.TABLE_NAME,2,LEN(B.TABLE_NAME))");
3151+
prepareMappingStatement.AppendLine(" AND A.COLUMN_NAME = B.COLUMN_NAME");
3152+
prepareMappingStatement.AppendLine(" AND B.TABLE_NAME LIKE '%_VW'");
3153+
prepareMappingStatement.AppendLine(" ) mapping");
31443154
prepareMappingStatement.AppendLine("LEFT OUTER JOIN dbo.MD_STG stg ON stg.STAGING_AREA_TABLE_NAME = mapping.TABLE_NAME");
31453155
prepareMappingStatement.AppendLine("LEFT OUTER JOIN dbo.MD_ATT stg_attr ON mapping.COLUMN_NAME = stg_attr.ATTRIBUTE_NAME");
31463156
prepareMappingStatement.AppendLine("JOIN MD_STG_SAT_XREF xref ON xref.STAGING_AREA_TABLE_ID = stg.STAGING_AREA_TABLE_ID");

0 commit comments

Comments
 (0)