create and update feature class

408
3
01-20-2012 04:36 PM
suhanatssuhanats
New Contributor
I have a python script to create featureclass from an sql server database table
the sql table gets updated everyday. So i want to find the max(id) from featureclass and select only those newer rows in sql table where id
greater than featureclass id and update it to feature class.
Tags (2)
0 Kudos
3 Replies
JakeSkinner
Esri Esteemed Contributor
Hi Suhanats,

You can find the max OBJECTID by appending the OIDs to a list and then retrieving the max value from the list.  Ex:

fc = "Airports"

OID_list = []

rows = arcpy.SearchCursor(fc, "", "", "OBJECTID")
for row in rows:
    OID_list.append(row.OBJECTID)

del row, rows

maxOID = max(OID_list)


Next you can use maxOID variable to select only the new records within the SQL table.
0 Kudos
RussellBrennan
Esri Contributor
There is a Summary Statistics tool in the analysis toolbox that will get you to get the max value for a field and output this value to a new table.
0 Kudos
suhanatssuhanats
New Contributor
thank you. i did a sort desc in the cursor and got the value of the field. i had to do this since the id value that i want is not the standard objectid field, but a user created field.
0 Kudos