Importing From an Oracle Spatial Database

AutoCAD Map 3D ObjectARX

 
Importing From an Oracle Spatial Database
 
 
 

Oracle Spatial Data (Overview) Related Samples

The "Importing From an Oracle Spatial Database" sample is an ObjectARX project located in the Map Samples\AcMapFlatOrclQuery folder in AutoCAD Map 3D ObjectARX installations.

Commands Implemented

The project creates an rx module which exposes the following commands.

  • ORAAPICONNECT — for connecting to the Oracle database.
  • ORAAPIIMPORT — for reviewing, composing, or running queries
  • ORAAPIDISCONNECT — for disconnecting.

Import dialog box

The ORAAPIIMPORT command opens the Import dialog box, which includes the following elements, among others.

  • Condition Samples — A list of conditions read from SqlWhereClauses.txt on the local machine. Click a condition to view or change it.
  • Connect — Click to connect to the Oracle database if not connected already.
  • Features — When connected, a list of features in the current schema. Click a feature and then click Get Aliases to display a list of aliases and corresponding names for the feature's tables. See "Table Aliases" below.

Table aliases

To compose a condition for a given feature, you have to specify which table to use if the feature has more than one, and you have to refer to this table by its alias. If there is only one table, its alias is "Table0" and specifying it is optional. The following condition uses a table alias.

      
Select *
From RIVERS Table0
Where Table.DEPTH > 5;

To get table aliases when there is more than one table for a feature, click Get Aliases in the Import dialog.

Column types

To write a condition, you may need the type of a given column. To get column types, click Describe Table in the Import dialog box to get information about any table in the current schema.

To create a query

  1. Select one or more features in the Features list box.
  2. Type a WHERE clause in the edit control below the Condition Samples list.

    The WHERE clause is applied to each of the selected features as it is typed, without checking to see if it is valid. If the condition is not valid — for example, if it references a table that does not belong to the feature — the query fails when it executes.

  3. Click View Sql Statement to see the corresponding SQL statement.

    If more than one feature is selected, there will be a corresponding number of SQL statements.

  4. Click Save to save the query for future use.
  5. Click Import to run the query and import objects.

To view a saved query

  • Click Load.

    This action loads a query from the table ADMPIMPORTSETTINGS in the current schema and displays its SQL statement in a separate dialog box. You can't execute the query, but you can view it, and you can copy parts of it to use in other queries.

To run a query

  • Click Import.

Note

Keep in mind that the purpose of this application is to instruct. It lacks extensive error handling. Use it with caution.