Exporting to an Oracle Spatial Database
Exporting to an Oracle Spatial Database
The following code sample illustrates exporting spatial data from a project drawing to an Oracle database.
Note The sample assumes an open project drawing
containing some objects. It also assumes that the connection object
is actually connected to a database. Click "Connecting to an Oracle
Database" for sample code.
Connecting to an Oracle Spatial Database (Sample) Exporting Data (Overview) Related Samples
#include "StdAfx.h"#include "StdArx.h"#include "AdMapOracleConnection.h"#include "AdMapOracleExport.h"BOOL ExportToOracle(){// Get connection pointerAcMapOSEConnection *pConnection = AcMapOracleGetConnection();// Declare export interfaceAcMapOSEExport *pExport = new AcMapOSEExport(pConnection);// Note: Before calling export functions, initialize the// export interface to specify export options and which// features to export// Export Option 1 - Export only new objects and erase// exported objects from the drawing// Empty feature vector means export all features in the// drawing database when you call export functionsstd::vector<std::string> vFeatureNames;// Initializeif(pExport->Init(vFeatureNames, kRemoveExported)){acutPrintf("\nInit() successful\n");// ExportAcDbDatabase *pDwg;// Get a valid drawing database reference for *pDwg// ... (add code here)if(pExport->ExportObjectsAll(pDwg)){acutPrintf("\nExport successful\n");}else{acutPrintf("\nExport failed\n");}}else{acutPrintf("\nExport->Init() failed\n");}// Export Option 2 - Export selected features, update// modified objects in Oracle, and delete erased objects// from OraclevFeatureNames.push_back("Feature1");vFeatureNames.push_back("Feature2");// Initializeif(pExport->Init(vFeatureNames,AcMapOSEExport::kUpdateModified |AcMapOSEExport::kUpdateErased |AcMapOSEExport::kRemoveExported)){acutPrintf("\nInit() successful\n");// Exportif(pExport->ExportObjectsAll(pDwg)){acutPrintf("\nExport successful\n");}else{acutPrintf("\nExport failed\n");}}else{acutPrintf("\nExport->Init() failed\n");}// Export Option 3 - Export a specific set of objects// Initialize - see initializing code samples above// ExportAcDbObjectIdArray idArray;// Populate idArray with a set of objects to export by// manually selecting or iterating through the drawing// database// ... (add code to populate idArray)if(pExport->ExportObjects(idArray);{acutPrintf("\nExport successful\n");}else{acutPrintf("\nExport failed\n");}delete pExport;
}