10.12.2012 Views

Oracle Spatial User's Guide and Reference - InfoLab

Oracle Spatial User's Guide and Reference - InfoLab

Oracle Spatial User's Guide and Reference - InfoLab

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Transactional Insert Operations Using SQL<br />

variable, <strong>and</strong> the host variable can be built using the SDO_GEOMETRY constructor<br />

with more than 999 values in the SDO_ORDINATE_ARRAY specification. (The host<br />

variable is an OCI, PL/SQL, or Java program variable.)<br />

To perform transactional insertions of geometries, you can create a procedure to<br />

insert a geometry, <strong>and</strong> then invoke that procedure on each geometry to be inserted.<br />

Example 3–4 creates a procedure to perform the insert operation.<br />

Example 3–4 Procedure to Perform a Transactional Insert Operation<br />

CREATE OR REPLACE PROCEDURE<br />

INSERT_GEOM(GEOM SDO_GEOMETRY)<br />

IS<br />

BEGIN<br />

INSERT INTO TEST_1 VALUES (GEOM);<br />

COMMIT;<br />

END;<br />

/<br />

Using the procedure created in Example 3–4, you can insert data by using a<br />

PL/SQL block, such as the one in Example 3–5, which loads a geometry into the<br />

variable named geom <strong>and</strong> then invokes the INSERT_GEOM procedure to insert that<br />

geometry.<br />

Example 3–5 PL/SQL Block Invoking a Procedure to Insert a Geometry<br />

DECLARE<br />

geom SDO_geometry :=<br />

SDO_geometry (2003, null, null,<br />

SDO_elem_info_array (1,1003,3),<br />

SDO_ordinate_array (-109,37,-102,40));<br />

BEGIN<br />

INSERT_GEOM(geom);<br />

COMMIT;<br />

END;<br />

/<br />

For additional examples with various geometry types, see the following:<br />

■ Rectangle: Example 2–2 in Section 2.3.1<br />

■ Polygon with a hole: Example 2–3 in Section 2.3.2<br />

■ Compound polygon: Example 2–5 in Section 2.3.4<br />

Loading <strong>Spatial</strong> Data 3-5

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!