inserting a feature ORA-00001: unique constraint

2767
1
07-31-2015 11:03 AM
marwamohamed
New Contributor

I am trying to insert a feature in a feature class but i get this error

"

Underlying DBMS error[ORA-00001: unique constraint (STATDB.R134_SDE_ROWID_UK) violated

]

" at this line   insertCursor.InsertFeature(destinationFeatureBuffer); in the code below

R134_SDE_ROWID_UK is the index with OBJECT column.

Here is the code

protected virtual void MigrateAfterMerge(MigrationFeatureClassSource source)

        {

            Stopwatch stopWatch = new Stopwatch();

            TimeSpan timeSpan;

            String elapsedTime;

          

            try

            {

                 stopWatch.Start();

                String groupFieldName = GetGrouByFieldName(source);

                if (groupFieldName != "")

                {

                    List<String> distinctValues = GetDistinctGroupFieldValues(source);

                    ESRI.ArcGIS.Geodatabase.IFeatureClass sourceFeatureClass = source.DataSource.GetFeatureWorkSpaceOfDataSource().OpenFeatureClass(source.SourceTableName);

                    ESRI.ArcGIS.Geodatabase.IFeatureClass destinationFeatureClass = Globals.GlobalsInstance.StandardDB.GetFeatureWorkSpaceOfDataSource().OpenFeatureClass(m_tableName);

                    String whereClause = "";

                    ESRI.ArcGIS.Geodatabase.IFeatureCursor insertCursor = destinationFeatureClass.Insert(false);

                    if (distinctValues != null)

                    {

                        foreach (String distinctValue in distinctValues)

                        {

                            if (distinctValue != "")

                            {

                                whereClause += groupFieldName + " = '" + distinctValue + "'";

                                ESRI.ArcGIS.Geometry.IPolygon unionedFeatures = Spatial_Operations.SpatialOperations.MergePolygonsWithCondition(sourceFeatureClass, whereClause);

                                ESRI.ArcGIS.Geodatabase.IFeatureBuffer destinationFeatureBuffer = CreateRecordInStandardDBFromMergeSource(destinationFeatureClass, source, unionedFeatures, ProcessValue(distinctValue, source));

                                insertCursor.InsertFeature(destinationFeatureBuffer);

                            }

                        }

                        // Flush the buffer to the geodatabase.

                        insertCursor.Flush();

                        stopWatch.Stop();

                        timeSpan = stopWatch.Elapsed;

                        elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",

                    timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds,

                    timeSpan.Milliseconds / 10);

                        Logger.LoggerInstance.LogOperationStatus(m_tableName + " - Migerating data from " + source.SourceName + " to standard DB succeeded", SyncOperationStatus.Succeded, m_tableName, DateTime.Now, elapsedTime);

                    }

                }

            }

            catch (Exception ex)

            {

               

                stopWatch.Stop();

                timeSpan = stopWatch.Elapsed;

                elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",

            timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds,

            timeSpan.Milliseconds / 10);

                Logger.LoggerInstance.LogOperationStatus(m_tableName + " -  Migerating data from " + source.SourceName + " to standard DB failed.", SyncOperationStatus.Failed, m_tableName, DateTime.Now, elapsedTime);

                Logger.LoggerInstance.LogError(ex.Message, DateTime.Now, "MigrateAfterMerge", "MigrationFeatureClass", m_tableName);

               

               throw new Exception(ex.Message);

            }

           

        }

0 Kudos
1 Reply
YuanLiu
Occasional Contributor

Can you please provide some more information? From what I can see, the insert workflow looks good. However there are many custom classes and functions we cannot check. This error message is not really telling us much. For now, one thing I would suggest is to double check the data integrity and repair. Sometimes corrupted data or orphan versions might cause this error. Or maybe log a technical support case to further look into it.