|
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.
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.
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 |
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 |
|