programmatically updating an SDE feature class referenced by an AGS service

636
5
03-25-2011 05:49 PM
ChrisBeaudette
Occasional Contributor
We're writing an app that will programmatically update an SDE feature class using the C API.  The SDE logic is a command-line C program, which accepts the usual SDE service flags:  -s server, -i instance, -d db, -u user, -p password.  The program reads from a DB table from which it will determine lat, long, attribute data, etc. and create a feature to insert into a feature class.  This feature class will, in turn, be referenced in a MXD that is used for an AGS MapServer service.

I've only ever seen that to modify a feature class (usually when using AGS toolbox tools and/or python scripts against it) there are locks that require that the AGS service be shut down, otherwise an error is thrown.  And even when shutting down the service, it seems that there are frequently persistent locks that need to be forcefully killed w/ sdemon.

We're actually re-writing an existing app that runs the update process in a nightly batch program, but users want to see the feature changes in "real time" (the C API is invoked by a .NET app which has an embedded map viewer), so we have to be able to update w/o shutting down the AGS service.

For additional background, the feature class is a simple feature class that is not versioned and does not participate in a topology or network or anything else.  ArcSDE version is 9.2 for Oracle and AGS version is 9.3.1. 

My question is:  Has anyone had similar issues with updating a feature class used by an AGS service (or otherwise have locks against it) and been able to work around them?  If so, how?
0 Kudos
5 Replies
ChrisBeaudette
Occasional Contributor
Disregard - found my answer here.
0 Kudos
VinceAngelo
Esri Esteemed Contributor
I had a similar need 11 years ago, so I wrote a 'C' utility I called 'sdeupdate' to modify the
rows in an SDE table in batch mode. It was designed to work with the output of 'sdequery'
with a WHERE clause that identified only the updated features. Both utilities are part of
the 'se_toolkit' suite, available by FTP download (the documentation has examples of
using the two piped together).

I regularly INSERT, UPDATE, and DELETE rows in non-versioned layers which are also
being served via AGS. If you are having SDE lock issues, it might be because you have
auto-locking enabled. You can disable autolocking with:

sdelayer -o alter -l table,geomcol -L OFF

Of couse, today you can modify the geometry when a coordinate column is updated by
using ST_GEOMETRY or a native geometry type with a trigger to execute the update
(which would yield real-time update, instead of updates dependent on the frequency
of batch execution).

- V
0 Kudos
IreneEgbulefu1
New Contributor III

Hi Vince 

Please do you still have the link to this FTP. I tried it but it is not working. I have a need to  INSERT, UPDATE, and DELETE rows in non-versioned layers in ArcSDE. 

I want to see if your 'C' utility here can provide me with the solution i need.

Thanks

Irene

0 Kudos
VinceAngelo
Esri Esteemed Contributor

Unfortunately, the ArcSDE API was deprecated at 10.2, and hasn't been available since 10.3.  `se_toolkit` survived (for 10.2.2 and before) until the FTP server was decommissioned.

You can certainly execute arbitrary SQL from ArcPy (with arcpy.ArcSDESQLExecute) and INSERT with arcpy.da.InsertCursor and UPDATE and DELETE with arcpy.da.UpdateCursor.

- V

0 Kudos
ChrisBeaudette
Occasional Contributor
Awesome, thanks Vince.
0 Kudos