///////////////////////////////////////////////////////////////////////////////////// public override void CreateJoinPourLiens( CFiltreData filtre, CArbreTable arbreTables, CComposantFiltre composantFiltre, ref bool bDistinct, ref string strJoin, ref string strWhere, ref string strPrefixeFrom) { strJoin = ""; arbreTables.SortTablesLiees(); foreach (CArbreTableFille arbreFils in arbreTables.TablesLiees) { strPrefixeFrom += "("; if (arbreFils.IsLeftOuter) { strJoin += " LEFT OUTER JOIN "; } else { strJoin += " INNER JOIN "; } if (arbreFils.Relation.IsRelationFille) { bDistinct = true; } string strTable; strTable = CContexteDonnee.GetNomTableInDbForNomTable(arbreFils.NomTable) + GetSqlForAliasDecl(arbreFils.Alias); string strSuiteFrom = ""; string strSuiteWhere = ""; string strPrefixe = ""; CreateJoinPourLiens(filtre, arbreFils, composantFiltre, ref bDistinct, ref strSuiteFrom, ref strSuiteWhere, ref strPrefixe); strJoin += strPrefixe; if (strSuiteFrom.Trim() != "") { strTable = "(" + strTable; } strTable += strSuiteFrom; if (strSuiteFrom.Trim() != "") { strTable += ")"; } strJoin += strTable; strJoin += " ON ("; CInfoRelationComposantFiltre relation = arbreFils.Relation; string strAliasParent, strAliasFille; string strTableDependante = ""; if (relation.IsRelationFille) { strAliasParent = arbreTables.Alias; strAliasFille = arbreFils.Alias; strTableDependante = arbreFils.NomTable; } else { strAliasParent = arbreFils.Alias; strAliasFille = arbreTables.Alias; strTableDependante = arbreTables.NomTable; } string strJointure = relation.GetJoinClause(strAliasParent, "", strAliasFille, ""); string strComplementVersion = ""; if (EstCeQueLaTableGereLesVersions(strTableDependante) && !filtre.IntegrerLesElementsSupprimes) { strComplementVersion = "(" + strAliasFille + "." + CSc2iDataConst.c_champIsDeleted + "=0 or " + strAliasFille + "." + CSc2iDataConst.c_champIsDeleted + " is null)"; } string strIdsVersionsALire = filtre.GetStringListeIdsVersionsALire(','); if (EstCeQueLaTableGereLesVersions(strTableDependante)) { if (strComplementVersion != "") { strComplementVersion += " and "; } if (strIdsVersionsALire == null) { strComplementVersion += strAliasFille + "." + CSc2iDataConst.c_champIdVersion + " is null"; } else { strComplementVersion += "(" + strAliasFille + "." + CSc2iDataConst.c_champIdVersion + " in (" + strIdsVersionsALire + ") or " + strAliasFille + "." + CSc2iDataConst.c_champIdVersion + " is null)"; } } if (strComplementVersion != "") { if (strWhere != "") { strWhere += " and (" + strComplementVersion + ") and ("; } else { strWhere += "("; } strWhere += strComplementVersion + ")"; } strJoin += strJointure + "))"; if (composantFiltre != null) { composantFiltre.DefinitAlias(arbreFils.CheminRelations, arbreFils.Alias); } if (filtre is CFiltreDataAvance) { foreach (CComposantFiltreChamp champ in ((CFiltreDataAvance)filtre).ChampsAAjouterAArbreTable) { champ.DefinitAlias(arbreFils.CheminRelations, arbreFils.Alias); } } } }
/// ///////////////////////////////////////////////////// public override void CreateJoinPourLiens( CFiltreData filtre, CArbreTable arbreTables, CComposantFiltre composantFiltre, ref bool bDistinct, ref string strFrom, ref string strWhere) { strFrom = ""; strWhere = ""; foreach (CArbreTableFille arbreFils in arbreTables.TablesLiees) { if (arbreFils.Relation.IsRelationFille) { bDistinct = true; } string strNomTableFils = CContexteDonnee.GetNomTableInDbForNomTable(arbreFils.NomTable); strNomTableFils = GetPrefixeForTable(arbreFils.NomTable) + strNomTableFils; strFrom += "," + strNomTableFils + GetSqlForAliasDecl(arbreFils.Alias); string strSuiteFrom = ""; string strSuiteWhere = ""; CreateJoinPourLiens(filtre, arbreFils, composantFiltre, ref bDistinct, ref strSuiteFrom, ref strSuiteWhere); if (strSuiteFrom != "") { strFrom += strSuiteFrom; } if (strWhere.Trim() != "" && strSuiteWhere.Trim() != "") { strWhere += " and (" + strSuiteWhere + ")"; } if (strWhere.Trim() == "" && strSuiteWhere.Trim() != "") { strWhere = strSuiteWhere; } //Equivalence WHERE ( MACOL = MACOL (+)) CInfoRelationComposantFiltre relation = arbreFils.Relation; string strAliasParent, strAliasFille; string strSuffixeParent = ""; string strSuffixeFils = ""; string strTableDependante = ""; if (relation.IsRelationFille) { strAliasParent = arbreTables.Alias; strAliasFille = arbreFils.Alias; strTableDependante = arbreFils.NomTable; if (arbreFils.IsLeftOuter) { strSuffixeFils = "(+)"; } } else { strAliasParent = arbreFils.Alias; strAliasFille = arbreTables.Alias; strTableDependante = arbreTables.Alias; if (arbreFils.IsLeftOuter) { strSuffixeParent = "(+)"; } } string strTmp = relation.GetJoinClause(strAliasParent, strSuffixeParent, strAliasFille, strSuffixeFils); string strComplementVersion = ""; if (EstCeQueLaTableGereLesVersions(strTableDependante) && !filtre.IntegrerLesElementsSupprimes) { strComplementVersion = "(" + strAliasFille + "." + CSc2iDataConst.c_champIsDeleted + "=0 or " + strAliasFille + "." + CSc2iDataConst.c_champIsDeleted + " is null)"; } string strIdsVersionsALire = filtre.GetStringListeIdsVersionsALire(','); if (EstCeQueLaTableGereLesVersions(strTableDependante)) { if (strComplementVersion != "") { strComplementVersion += " and "; } if (strIdsVersionsALire == null) { strComplementVersion += strAliasFille + "." + CSc2iDataConst.c_champIdVersion + " is null"; } else { strComplementVersion += "(" + strAliasFille + "." + CSc2iDataConst.c_champIdVersion + " in (" + strIdsVersionsALire + ") or " + strAliasFille + "." + CSc2iDataConst.c_champIdVersion + " is null)"; } } if (strComplementVersion != "") { if (strTmp != "") { strTmp = "((" + strTmp + ") and "; } else { strAliasFille += "("; } strTmp += strComplementVersion + ")"; } if (strWhere.Trim() != "") { strWhere = "(" + strTmp + ") and (" + strWhere + ")"; } else { strWhere = strTmp; } if (composantFiltre != null) { composantFiltre.DefinitAlias(arbreFils.CheminRelations, arbreFils.Alias); } } }