Spatial OCI sample code

This sample code includes two programs, writegeom and readgeom, that illustrate the use of OCI in writing and reading spatial data from and to Oracle8i.

Give us feedback

Download the zip file for NT
Download tar file for Unix

Prerequisites

  • Oracle Spatial, release 8.1.5 (or higher)

  • Oracle8i, release 8.1.5 (or higher)

  • An Oracle username and password

  • A table named test_insert which contains at least two columns of name and type:
    • gid NUMBER (unique id number for the geometry)
    • geometry mdsys.sdo_geometry (stores the geometry)

  • Oracle client software (if sample programs are not installed on the same system as the Oracle server)

  • ORACLE_HOME environment variable set to point to the instance containing the table test_insert

  • In the sample programs, the <dblink> argument value of the function OCIServerAttach() set to reflect the host name of the system running the Oracle server.

 

Compiling the sample programs

See the file oci_sample.mk for instructions to compile the sample code.

The following OCI object functions are used in the code. For more information, review the Oracle Call Interface Programmer's Guide - Part II: OCI Object Concepts

  • OCIDescribeAny()
  • OCIObjectNew()
  • OCIDefineObject()
  • OCIObjectPin(),
  • OCIObjectFree()

Using the writegeom sample

writegeom includes a hardcoded list of data. It uses this data to create the geometries that it loads into the table test_insert. Feel free to modify the program to obtain geometry data from another source.

  • Invoke writegeom from the command line by typing:

    writegeom <username> <password>

Using the readgeom sample

readgeom is a generic program that can read greometries from a user specified table with a column of type mdsys.sdo_geometry, and with any number of coordinates per point or vertex for the stored geometry.

  • Invoke readgeom from the command line by typing:

    readgeom <username> <password> <table name> <geometry column name> <number of coordinates>

Where:

<username>
<password>
- your Oracle username and password
<table name> - a table with a column of type mdsys.sdo_geometry
<geometry column name> - the column of type mdsys.sdo_geometry
<number of coordinates> - the number of coordinates per point or vertex for the geometry

  • Using the default information provided in this example, the command line is:

    readgeom <username> <password> test_insert geometry 2

Where:

<username>
<password>
- enter your Oracle username and password
test_insert - is the table with a column of type mdsys.sdo_geometry
geometry - is the the column of type mdsys.sdo_geometry
2 - is the number of coordinates per point or vertex for the geometry

 

 

 

E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy