<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Database/ field editing performance regarding contingent values? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/database-field-editing-performance-regarding/m-p/1326569#M68544</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a quick question regarding contingent values and the potential impacts that it may have on performance either with editing in the field or the database itself. I have a script that creates all potential combinations and adds them as contingent values. Depending on what limitations or restrictions I set, I get a varying number of possible outcomes ranging from 300 to over 1000. Here is part of the script that I have that creates all possible combinations and returns a list of strings that are then added as contingent values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from itertools import permutations, combinations

# Contingent values function
def CreateContingentStringValues( Fields, Condition, DomainType, DomainCodes, Constraints, SetNullConditions,  ExistingValues ):
    Equal, NotEqual, GreatThan, LessThan = '=', '!=', '&amp;gt;', '&amp;lt;' 
    FieldIndexing = { fieldname : index for index, fieldname in enumerate( Fields ) }
    
    Combinations = None
    if len( Fields ) &amp;gt;= 2:
        if Condition == NotEqual:
            Combinations = list( list( combinations( DomainCodes, len( Fields ) ) ) )
        elif Condition == Equal:
            Combinations = list( list( permutations( DomainCodes, len( Fields ) ) ) )
        elif Condition in [ GreatThan, LessThan ]:
            pass
    
    ValidCombinations = []
    if Combinations:
        for Combination in Combinations:
            ValidateCombinations = len( set( Constraints ).intersection( set( Combination ) ) ) &amp;lt; 2
            CombinationOrder = [ Constraints[ value ] for value in Combination if value in Constraints ]
            SortedOrder = sorted( CombinationOrder, reverse = True )
            ValidateOrder = all( [ True if any( [ a == b, a &amp;gt; b ] ) else False for a, b in zip( SortedOrder, CombinationOrder ) ] )
            if all( [ ValidateCombinations, SetNullConditions not in Combination, ValidateOrder ] ):
                ValidCombinations += [ Combination ]
    
    ValuesString = [ ]
    if ValidCombinations:
        for Combination in ValidCombinations:
            FieldValueDict = dict( zip(  Fields, Combination ) )
            ListStrFieldNameValue = [ f'{ FieldName } { DomainType } { FieldValueDict[ FieldName ] }' for FieldName in FieldValueDict ]
            StrValue = ';'.join( ListStrFieldNameValue )
            if StrValue not in ExistingValues:
                ValuesString += [ StrValue ]
            
    if type( SetNullConditions ) is str:
        ListStrFieldNameValue = [ f'{ FieldName } { DomainType } { SetNullConditions }'  if FieldIndexing[ FieldName ] == 0 else  f'{ FieldName } NULL { SetNullConditions }' for FieldName in FieldIndexing ]
        StrValue = ';'.join( ListStrFieldNameValue )
        if StrValue not in ExistingValues:
            ValuesString += [ StrValue ]
            
    return ValuesString&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It works but my concern is the impact that it may have on our field editors. Any help or input would be greatly appreciated.&lt;/P&gt;</description>
    <pubDate>Fri, 08 Sep 2023 13:02:39 GMT</pubDate>
    <dc:creator>RPGIS</dc:creator>
    <dc:date>2023-09-08T13:02:39Z</dc:date>
    <item>
      <title>Database/ field editing performance regarding contingent values?</title>
      <link>https://community.esri.com/t5/python-questions/database-field-editing-performance-regarding/m-p/1326569#M68544</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a quick question regarding contingent values and the potential impacts that it may have on performance either with editing in the field or the database itself. I have a script that creates all potential combinations and adds them as contingent values. Depending on what limitations or restrictions I set, I get a varying number of possible outcomes ranging from 300 to over 1000. Here is part of the script that I have that creates all possible combinations and returns a list of strings that are then added as contingent values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from itertools import permutations, combinations

# Contingent values function
def CreateContingentStringValues( Fields, Condition, DomainType, DomainCodes, Constraints, SetNullConditions,  ExistingValues ):
    Equal, NotEqual, GreatThan, LessThan = '=', '!=', '&amp;gt;', '&amp;lt;' 
    FieldIndexing = { fieldname : index for index, fieldname in enumerate( Fields ) }
    
    Combinations = None
    if len( Fields ) &amp;gt;= 2:
        if Condition == NotEqual:
            Combinations = list( list( combinations( DomainCodes, len( Fields ) ) ) )
        elif Condition == Equal:
            Combinations = list( list( permutations( DomainCodes, len( Fields ) ) ) )
        elif Condition in [ GreatThan, LessThan ]:
            pass
    
    ValidCombinations = []
    if Combinations:
        for Combination in Combinations:
            ValidateCombinations = len( set( Constraints ).intersection( set( Combination ) ) ) &amp;lt; 2
            CombinationOrder = [ Constraints[ value ] for value in Combination if value in Constraints ]
            SortedOrder = sorted( CombinationOrder, reverse = True )
            ValidateOrder = all( [ True if any( [ a == b, a &amp;gt; b ] ) else False for a, b in zip( SortedOrder, CombinationOrder ) ] )
            if all( [ ValidateCombinations, SetNullConditions not in Combination, ValidateOrder ] ):
                ValidCombinations += [ Combination ]
    
    ValuesString = [ ]
    if ValidCombinations:
        for Combination in ValidCombinations:
            FieldValueDict = dict( zip(  Fields, Combination ) )
            ListStrFieldNameValue = [ f'{ FieldName } { DomainType } { FieldValueDict[ FieldName ] }' for FieldName in FieldValueDict ]
            StrValue = ';'.join( ListStrFieldNameValue )
            if StrValue not in ExistingValues:
                ValuesString += [ StrValue ]
            
    if type( SetNullConditions ) is str:
        ListStrFieldNameValue = [ f'{ FieldName } { DomainType } { SetNullConditions }'  if FieldIndexing[ FieldName ] == 0 else  f'{ FieldName } NULL { SetNullConditions }' for FieldName in FieldIndexing ]
        StrValue = ';'.join( ListStrFieldNameValue )
        if StrValue not in ExistingValues:
            ValuesString += [ StrValue ]
            
    return ValuesString&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It works but my concern is the impact that it may have on our field editors. Any help or input would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2023 13:02:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/database-field-editing-performance-regarding/m-p/1326569#M68544</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2023-09-08T13:02:39Z</dc:date>
    </item>
  </channel>
</rss>

