laptop and a wrench

Bug

An error is not generated on a call to IFeature::Store when it should be.

Last Published: August 31, 2014 No Product Found
Bug ID Number NIM088716
SubmittedFebruary 1, 2013
Last ModifiedApril 2, 2025
Applies toNo Product Found
Version found10.1
Program languageC++
StatusWill Not Be Addressed

Additional Information

We apologize that we were unable to address this issue within the current product support cycle. If the issue continues to affect your work in a supported release, please contact Technical Support.

Workaround

For this case an InsertCursor can be used in place of the IFeatureClass::CreateFeature...IFeature::Store workflow that is currently used in the sample code. int main( int argc, char* argv[] ){ std::string inputFileName = "<a href="file:X://testing3.gdb" target="_blank">X:\\testing3.gdb</a>"; std::string tableName = "Airspace"; std::string sdeFilePath = "<a href="file:C://Connection" target="_blank">C:\\Connection</a> to sql2008R2.sde"; std::string qualifiedTableName("loaded.DBO.AAA_POLYTEST_UNKNOWN"); HRESULT hr = S_OK; IAoInitializePtr ipInit = NULL; AoInitialize(NULL); hr = ipInit.CreateInstance( CLSID_AoInitialize ); if(FAILED(hr) || !ipInit) exit(-1); esriLicenseStatus license_status; ipInit->IsProductCodeAvailable( esriLicenseProductCodeAdvanced, &license_status ); if(license_status == esriLicenseAvailable) { esriLicenseStatus status = esriLicenseFailure; ipInit->Initialize(esriLicenseProductCodeAdvanced, &status ); if( status != esriLicenseCheckedOut ) throw std::string("Unable to get license"); } do { std::cout << "creating source workspace ..." << std::endl; IWorkspacePtr ipSrcWorkspace = NULL; if( FAILED( hr = createSourceWorkspace( ipSrcWorkspace, inputFileName ) ) ) break; IFeatureWorkspacePtr ipSrcFeatureWorkspace = ipSrcWorkspace; ITablePtr ipSrcTable = NULL; if( FAILED( hr = ipSrcFeatureWorkspace->OpenTable(CComBSTR(tableName.c_str()), &ipSrcTable ) ) ) break; ICursorPtr ipSrcCursor = NULL; if( FAILED( hr = ipSrcTable->Search( NULL, VARIANT_TRUE, &ipSrcCursor ) ) ) break; IFeatureCursorPtr ipSrcFeatureCursor = ipSrcCursor; std::cout << "creating destination workspace ..." << std::endl; IWorkspacePtr ipDstWorkspace = NULL; if( FAILED( createDestinationWorkspace( ipDstWorkspace, sdeFilePath) ) ) break; IFeatureWorkspacePtr ipDstFeatureWorkspace = ipDstWorkspace; ITablePtr ipDstTable = NULL; if( FAILED( hr = ipDstFeatureWorkspace->OpenTable( CComBSTR(qualifiedTableName.c_str()), &ipDstTable ) ) ) break; IFeatureClassPtr ipDstFeatureClass = ipDstTable; IWorkspaceEditPtr ipWorkspaceEdit = ipDstWorkspace; if( FAILED( hr = ipWorkspaceEdit->StartEditing(VARIANT_FALSE) ) ) break; if( FAILED( hr = ipWorkspaceEdit->StartEditOperation() ) ) break; IFeatureCursorPtr ipDstFeatureCursor = NULL; if( FAILED( hr = ipDstFeatureClass->Insert(VARIANT_TRUE, &ipDstFeatureCursor ) ) ) { std::cout << "failed to..." << std::endl; break; } std::cout << "Truncating table '" << qualifiedTableName << "' ... "; if( FAILED( hr = ipDstTable->DeleteSearchedRows(NULL) ) ) { std::cout << "failed to trunctate destination table - aborting" << std::endl; break; } std::cout << "Done" << std::endl; IVersionedObjectPtr ipVersionedObject = ipDstTable; if( ipVersionedObject ) { VARIANT_BOOL isVersioned = VARIANT_FALSE; if( SUCCEEDED( ipVersionedObject->get_IsRegisteredAsVersioned(&isVersioned) ) ) { if( !isVersioned ) { std::cout << "table is not versioned - aborting" << std::endl; break; } } } IFeaturePtr ipSrcFeature = NULL; for( int count = 1; true; ++count ) { hr = ipSrcFeatureCursor->NextFeature( &ipSrcFeature ); if( ipSrcFeature == NULL ) break; long objectID = NULL; ipSrcFeature->get_OID(&objectID); IGeometryPtr ipSrcGeometry = NULL; hr = ipSrcFeature->get_Shape( &ipSrcGeometry ); IFeatureBufferPtr ipDstFeatureBuffer = NULL; if( FAILED( hr = ipDstFeatureClass->CreateFeatureBuffer( &ipDstFeatureBuffer ) ) ) { std::cout << std::endl << "unable to create a feature class for output - aborting" << std::endl; return hr; } if( count == 4467 || count == 4524 ) { std::cout << std::endl << "about to store 'bad' feature with OBJECTID_1=" << count << std::endl; } hr = ipDstFeatureBuffer->putref_Shape(ipSrcGeometry); CComVariant id = NULL; if( FAILED( hr = ipDstFeatureCursor->InsertFeature(ipDstFeatureBuffer, &id) ) ) { std::cout << std::endl << "Store() failed with error code: " << hr << " with OBJECTID_1=" << objectID << std::endl; } if( count % 100 == 0 ) { ipDstFeatureCursor->Flush(); } } ipDstFeatureCursor->Flush(); if( FAILED( hr = ipWorkspaceEdit->StopEditOperation() ) ) { std::cout << std::endl << "STOP OP: " << hr << std::endl; break; } if( FAILED( hr = ipWorkspaceEdit->StopEditing( VARIANT_TRUE ) ) ) { std::cout << std::endl << "STOP EDIT: " << hr << std::endl; break; } } while( false ); if( hr != S_OK ) { std::cout << std::endl << "An error occurred with code:" << hr << std::endl; return hr; } ipInit = NULL; AoUninitialize(); return EXIT_SUCCESS;}

Steps to Reproduce

Bug ID: NIM088716

Software:

  • No Product Found

Get notified when the status of a bug changes

Download the Esri Support App

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options