The idea is, that user makes custom selection, not necessary by atributes or location, he may as well do it by simply clicking feature, so it doesn't solve the problem. Below is my code, maybe it helps somehow 🙂
DICT_VALUES = {'Tak': 'T',
'Nie': 'F',
'Bez zmian': None}
def updateDb(cur, field, value, teryts):
update_string = "Update PLOTS set " + str(field) + " = '" + str(value) + "' where TERYT = :teryt"
cur.prepare(update_string)
for teryt in teryts:
arcpy.AddMessage('Setting ' + field + ' to ' + value + ' for plot ' + teryt)
cur.execute(None, {'teryt': str(teryt)})
con.commit()
import arcpy
import sys
try:
import cx_Oracle as cxo
except ImportError:
arcpy.AddError('cx_Oracle module not found. Add module to sys.path or install module if necessary')
sys.exit()
plots = sys.argv[1]
arcpy.AddMessage('Processing selection')
rows = arcpy.SearchCursor(plots)
teryt_nr = []
for plot in rows:
if plot.TERYT:
teryt_nr.append(plot.TERYT)
arcpy.AddMessage('Connecting to DB...')
con = cxo.connect('user/pass@db')
cur = con.cursor()
#
## POI
if DICT_VALUES[sys.argv[2]]:
updateDb(cur, 'POI', DICT_VALUES[sys.argv[2]], teryt_nr)
What I need is empty list "teryt_nr" in case where there is no selection on layer in arcmap 🙂