ArcObjects Library Reference  (GeoDatabase)    

IFeatureClass.Insert Method

Returns a cursor that can be used to insert new features.

[Visual Basic 6.0]
Function Insert(
    ByVal useBuffering As Boolean _
) As IFeatureCursor
[Visual Basic .NET]
Public Function Insert ( _
    ByVal useBuffering As Boolean _
) As IFeatureCursor
[C#]
public IFeatureCursor Insert (
    bool useBuffering
);
[Java]
public IFeatureCursor insert (
    Boolean useBuffering
)
throws
    IOException,
    AutomationException
[C++]
HRESULT Insert(
  VARIANT_BOOL useBuffering,
  IFeatureCursor** Cursor
);
[C++]

Parameters

useBuffering [in]

  useBuffering is a parameter of type VARIANT_BOOL

Cursor [out, retval]

  Cursor is a parameter of type IFeatureCursor

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Remarks

Insert creates an insert cursor on the feature class which can be used to insert new features into it.

Insert cursors can be used on instances of feature subclasses (such as network features) with guaranteed polymorphic behavior. Insert cursors can be used either inside or outside of an edit session. If used inside an edit session, the changes are not committed to the base table until the edit session is saved. Network feature classes, Topology feature classes, feature classes that participate in composite relationships or other relationships with messaging may only be updated within an edit session. If you attempt to use an insert cursor on one of these classes outside of an edit session, it will fail. In addition, inserts of features that participate in a Topology or Geometric Network must be bracketed within an edit operation.

If the insert cursor is created outside of an edit operation and new features are inserted within an edit operation, the changes are commited to the base tables.  The additions to the base table cannot be undone.  For this reason, insert cursors should typically be scoped to edit operations.

When using an insert cursor with simple features, IFeature.Store will not be called when a feature is inserted. If a class extension, editor extension or other custom implementation relies on the messages propagated from the Store method, this could cause a problem. The IObjectClassInfo interface can be implemented by a class extension to force a Store call when an insert cursor is used. Alternately, requiring Store calls can be specified across a workspace by setting the IWorkspaceEditControl.SetStoreEventsRequired property to true.

If the insert cursor is used to insert complex features (such as network features), the cursor will revert to using IFeature.Store.

 

[Visual Basic 6.0]

The following code will insert a new feature into the feature class using an insert cursor.

 Dim pFeatcls As IFeatureClass
 Dim pFeatLayer As IFeatureLayer
 Dim pDoc As IMxDocument
 Dim pMap As IMap
 
 Set pDoc = ThisDocument
 Set pMap = pDoc.Maps.Item(0)
 Set pFeatLayer = pMap.Layer(0)
 Set pFeatcls = pFeatLayer.FeatureClass
 
 Dim pFeatCur As IFeatureCursor
 Dim pFeatBuf As IFeatureBuffer
 Dim v As Variant
 
 Set pFeatCur = pFeatcls.Insert(True)
 Set pFeatBuf = pFeatcls.CreateFeatureBuffer
 v = pFeatCur.InsertFeature(pFeatBuf) 

See Also

IFeatureClass Interface | IFeature Interface | IFeatureCursor Interface

Example

IFeatureClass.Insert Example