ExistsObjectsWhere (exp)
function ExistsObjectsWhere(iClassName:string; iExpression:string):Integer;
Retourne 1 si il existe au moins un objet de iClassName vérifiant iExpression; retourne 0 sinon.
Exemples :
Utilisation de ExistsObjectWhere pour charger des objets dans une liste
var aList:TConstitutionSectionGCList;
begin
aList := TConstitutionSectionGC.CreateList;
aList.AddWhere('ExistsObjectsWhere(''TIdentificationCentreGC'',''(oidConstitutionSectionGC=self.oid) and (identificationCentreNF<>%1)'')','','',True,-1,['']);
for idx := 0 to aList.count-1 do
begin
end;
end;
Dans cet exemple la liste est chargée des objets de TConstitutionSectionGC pour lesquels il existe au moins une TidentificationCentreGC dont l'identificationCentreNF est non vide.
Notez :
- Le doublage des quotes nécessaires pour les arguments de ExistObjectsWhere
- L'utilisation de self pour faire référence au contexte de TConstitutionSectionGC dans la requête sur les TIdentificationCentreGC.
Utilisation de ExistsObjectWhere pour rechercher un objet
//procedure RegleAlerte_EtatMetierList:boolean;
var obj:TEtatPossible;
begin
//...
obj := ClassManager.FindObject(
'TEtatPossible',
'(oidCircuitValidation = %1) and (ExistsObjectsWhere(''TEtatEngagement'',''(oid = self.oidEtatMetier) and (autorisePropositionAchat = True)''))',
'ordre',True,
[instanceOID]);
end;
Dans cet exemple un objet de TEtatPossible ayant comme circuit de validation l'objet courant et pour lequel il existe au moins un TEtatEngagement pour lequel autorisePropositionAchat est vrai.
Voir aussi: