Mdsys.sdo_geometry ( 2007 , ....
Hello,
I have one table with polygons (one by row, so sdo_gtype=2003 ) and I want to take some of them and place it in one single row of another table defined by sdo_gtype=2007 (multipolygon)
I don't know if it's possible and how I can do that
I know how to recover the sdo_ordinates and the
sdo_elem_info but i don't know how to insert it in the field SHAPE of my new table
Thanks a lot
taofoo
hi,
You might want to let spatial create the geometry for you using sdo_geom.sdo_union. That was you can be sure the new geometry will be legal (it will be a multi-polygon if necessary, but also it will appropriately not create single elelments which overlap).
Similar Messages
-
Calling a SP or Function from Java receiving a geometry(MDSYS.SDO_GEOMETRY)
Hi there,
What I want to do is: calling a stored procedure OR function from Java with a String-variable as input and receiving a geometry (SDO_GEOMETRY).
I’m facing currently the problem of calling a stored function on oracle 11g from Java using JPA (EclipseLink), Spring 2.5.6 returning an MDSYS.SDO_GEOMETRY object.
I’ve tried to call a stored procedure with MDSYS.SDO_GEOMETRY as an output parameter instead, but with no success.
The function’s signature looks like this:
CREATE or REPLACE
FUNCTION GET_GEO_BRD_FUNCTION(p_geo_brd_id IN VARCHAR2) RETURN MDSYS.SDO_GEOMETRY AS
sdo_geom MDSYS.SDO_GEOMETRY := null;
BEGIN
/* do some fancy stuff on the database side */
SELECT sp_geom
INTO sdo_geom
FROM geo_brd WHERE id = p_geo_brd_id;
RETURN sdo_geom;
END;
The calling code looks like this:
MyClass extends JpaDaoSupport{
/** logger */
protected static final ILogger LOG = LogFactory.getLogger(MyClass.class);
* {@inheritDoc}
* @see com.example.MyClass#calculateGeometry(java.lang.String)
@Override
public JGeometry calculateGeometry(final String id) {
JGeometry geometry = null;
final JpaCallback action = new JpaCallback() {
@Override
public Object doInJpa(final EntityManager em) throws PersistenceException {
final Session session = JpaHelper.getEntityManager(em).getActiveSession();
final StoredFunctionCall functionCall = new StoredFunctionCall();
functionCall.setProcedureName("GET_GEO_BRD_FUNCTION");
functionCall.addNamedArgument("p_geo_brd_id");
functionCall.setResult("sdo_geom", Oracle.sql.STRUCT.class);
final ValueReadQuery query = new ValueReadQuery();
query.setCall(functionCall);
query.addArgument("p_geo_brd_id");
final ArrayList args = new ArrayList();
args.add("2e531e62-2105-4522-978a-ab8baf19e273");// hardcoded for test
final Object result = session.executeQuery(query, args);
return result;
final STRUCT result = (STRUCT) this.getJpaTemplate().execute(action);
try {
geometry = JGeometry.load(result);
} catch (final SQLException e) {
MyClass.LOG.error("Error loading JGeometry from STRUCT.", e);
return null;
return geometry;
And when I execute the query I get the following error:
Internal Exception: java.sql.SQLException: ORA-06550: Row 1, Column 13:
PLS-00382: expression is of wrong type
ORA-06550: Row 1, Column 7:
PL/SQL: Statement ignored
Error Code: 6550
Call: BEGIN ? := GET_GEO_BRD_FUNCTION(p_geo_brd_id=>?); END;
bind => [=> sdo_geom, 2e531e62-2105-4522-978a-ab8baf19e273]
Query: ValueReadQuery()
So I thought may be let's try it with a stored procedure instead...
The procedure looks like this:
CREATE or REPLACE
PROCEDURE GET_GEO_BRD_PROCEDURE(p_geo_brd_id IN VARCHAR2, sdo_geom OUT MDSYS.SDO_GEOMETRY) AS
BEGIN
/* do some fancy stuff on the database side */
SELECT sp_geom
INTO sdo_geom
from geo_brd where id = p_geo_brd_id;
END;
The calling Java code in case of the stored procedure looks like this (only the content of the JPACallback has changed):
@Override
public Object doInJpa(final EntityManager em) throws PersistenceException {
final Session session = JpaHelper.getEntityManager(em).getActiveSession();
final StoredProcedureCall spCall = new StoredProcedureCall();
spCall.setProcedureName("GET_GEO_BRD_PROCEDURE");
spCall.addNamedArgument("p_geo_brd_id", "p_geo_brd_id", String.class);
spCall.addNamedOutputArgument("sdo_geom", "sdo_geom", OracleTypes.STRUCT);
final ValueReadQuery query = new ValueReadQuery();
query.setCall(spCall);
query.addArgument("p_geo_brd_id"); // input
final List args = new ArrayList();
args.add("2e531e62-2105-4522-978a-ab8baf19e273");// hardcoded for test
final Object result = session.executeQuery(query, args);
return result;
And when I execute the query I get the following error:
java.sql.SQLException: ORA-06550: Row 1, Column 13:
PLS-00306: wrong number or types of arguments in call to 'GET_GEO_BRD_PROCEDURE'
ORA-06550: Row 1, Column 7:
PL/SQL: Statement ignored
So both exceptions look quite similar.
I guess in both cases the exception description leads to the assumption, that the wrong type for the return value / output parameter is used…
So - how can a receive a MDSYS_SDO_GEOMETRY object from a stored procedure or stored function in Java ?
What is wrong in the Java code?
Thank you in advance for any suggestions!
Yours,
Chris
Edited by: user3938161 on 20.12.2011 07:46
Edited by: user3938161 on Dec 20, 2011 8:06 AM: added variable declaration of JGeometry geometry in source codeThanks, that did the trick! ;-)
Here is now the code for stored procedure and function for anybody else encountering the same troubles... (be aware of the parameter order and/or naming!)
Code for stored functions:
final JpaCallback action = new JpaCallback() {
@Override
public Object doInJpa(final EntityManager em) throws PersistenceException {
final Session session = JpaHelper.getEntityManager(em).getActiveSession();
* Using CallableStatement for stored functions
STRUCT st = null;
CallableStatement cs = null;
final DatabaseLogin login = session.getLogin();
final Connection _conn = (Connection) login.connectToDatasource(session.getDatasourceLogin().buildAccessor(), session);
try {
try {
cs = _conn.prepareCall("{? = call GET_GEO_BRD_FUNCTION(?)}");
cs.registerOutParameter(1, OracleTypes.STRUCT, "MDSYS.SDO_GEOMETRY");
cs.setString(2, "2e531e62-2105-4522-978a-ab8baf19e273");//TODO: hardcoded for test
cs.execute();
} catch (final SQLException e) {
MyClass.LOG.error("An exception occured calling the stored procedure", e);
if (cs != null) {
//reading geometry from the database
try {
st = (STRUCT) cs.getObject(1);
} catch (final SQLException e) {
MyClass.LOG.error("An exception occured converting the query result to oracle.sql.STRUCT", e);
} finally {
try {
if (_conn != null && !_conn.isClosed()) {
_conn.close();
} catch (final SQLException e) {
MyClass.LOG.error("An exception occured on closing the database connection.", e);
return st;
final STRUCT result = (STRUCT) this.getJpaTemplate().execute(action);
The code for stored procedure solution:
final JpaCallback action = new JpaCallback() {
@Override
public Object doInJpa(final EntityManager em) throws PersistenceException {
final Session session = JpaHelper.getEntityManager(em).getActiveSession();
* Using CallableStatement for stored procedure
STRUCT st = null;
CallableStatement cs = null;
final DatabaseLogin login = session.getLogin();
final Connection _conn = (Connection) login.connectToDatasource(session.getDatasourceLogin().buildAccessor(), session);
try {
try {
cs = _conn.prepareCall("{call GET_GEO_BRD_PROCEDURE(?,?)}");
cs.setString("p_geo_brd_id", "2e531e62-2105-4522-978a-ab8baf19e273");
cs.registerOutParameter("sdo_geom", OracleTypes.STRUCT, "MDSYS.SDO_GEOMETRY");
cs.execute();
} catch (final SQLException e) {
MyClass.LOG.error("An exception occured calling the stored procedure", e);
if (cs != null) {
//reading geometry from the database
try {
st = (STRUCT) cs.getObject("sdo_geom");
} catch (final SQLException e) {
MyClass.LOG.error("An exception occured converting the query result to oracle.sql.STRUCT", e);
} finally {
try {
if (_conn != null && !_conn.isClosed()) {
_conn.close();
} catch (final SQLException e) {
MyClass.LOG.error("An exception occured on closing the database connection.", e);
return st;
final STRUCT result = (STRUCT) this.getJpaTemplate().execute(action); -
Geomtry to mdsys.sdo_geometry
Hi, i'm a newbie of Oracle Spatial, i'm working with sdoapi, i need to convert
geometries encoded with GML into valid geometries encoded in msdsys.sdo_geometry
to perform query throug SQL over other geoemtries stored into a table.
For example, if i've a box geometry in GML like this:
<gml:Box>
<gml:coord>
<gml:X>-103</gml:X>
<gml:Y>31</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>-103.5</gml:X>
<gml:Y>31.5</gml:Y>
</gml:coord>
</gml:Box>
I would make a query like:
SELECT a.geometry
FROM My_Spatial_Table a
WHERE mdsys.sdo_relate(a.geometry, mdsys.sdo_geometry (2003, null, null,mdsys.sdo_elem_info_array (1,1003,3),mdsys.sdo_ordinate_array (-103,31,-103.5,31.5)),'querytype=WINDOW layer_gtype=notpoint') = 'TRUE';
I've look in sdoapi's samples that i can make an adapter from my
GML (XML) to Oracle's geometry, now i would know if i can map
this geometry into a mdsys.sdo_geometry form.
For geometries like point, box, there's no problems, but for geometries
like polygon, linestring, multipolygon i don't know how do this! :-(
Any tips or documentation for my problem?
Best Regards
LuigiAre you positive that the data is only being saved
with 6 places of precisions ?
As far as I remember SQLPlus only displays up to 6
decimal points, although there are more in the data.
I remember a similar thread on this before where
there was a Tip that suggested setting the SQLPlus
number format highr in order to display the full
coordinates.
e.g. SET NUMFORMAT 9999999999999999.99999999999999999999999;
Ro -
How to retreive x/y from mdsys.sdo_geometry
I need to retreive the coord pair for a point table. If I use:
select p.id, p.shape.sdo_point.x, p.shape.sdo_point.y from pointdatastore p
the returned result is null. Said table was created from ESRI tools via ArcSDE which I believe is the root problem. I'm a newbie to Spatial but a lot of years with ESRI tools.
Any help.Neil,
Are you certain ESRI is storing the points as a SDO_POINT type? Although I do not know for certain I expect they are not - which is why you would be coming up with NULLs. Rather ESRI is probably using the ordinate array which you can select vertices from using SDO_UTIL.GETVERTICES (which is found in Oracle Spatial). here's the corresponding documentation:
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14255/sdo_util.htm#BABDEGIA
I hope this helps.
-Justin -
Get all vertices from a geometry of multiple polygons
I tried to use sdo_util.GetVertices to retrieve all the vertices from a geometry column. Some of the geometries of gType 2007 that contains more than one element. The getVertices function seems to give back the vertices of the first element only. How can I get all the vertices then?
Edited by: 937152 on May 29, 2012 11:56 AMWhy do you have all the NULLs in your sdo_elem_info_array and sdo_ordinate_array? This is very very wrong - see http://docs.oracle.com/cd/E11882_01/server.112/e17766/e12700.htm#sthref3897
Despite that I am able to get all the "vertices" back from your sample geometry - note that I changed your SELECT statement a little.
jot_test@JOHNOT> create table assessment_parcel_merged (
2 id number,
3 geometry sdo_geometry);
Table created.
jot_test@JOHNOT>
jot_test@JOHNOT> insert into assessment_parcel_merged
2 (id, geometry)
3 values
4 (506833,
5 mdsys.sdo_geometry(2007,82232,null,
6 mdsys.sdo_elem_info_array(1,1003,1,13,1003,1,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null),
7 mdsys.sdo_ordinate_array(632941.3695,5536245.0144,632939.95209944,5536241.97593627,633251.020958124,5536096.38289373,633369.443364573,5536040.95632826,633371.0274,5536043.9168,632941.3695,5536245.0144,631892.0616,5536736.1337,631892.8842984,5536702.62493823,632873.47478553,5536243.66593412,632884.740084103,5536267.81696815,632886.1576,5536270.8559,631892.0616,5536736.1337,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null)));
1 row created.
jot_test@JOHNOT>
jot_test@JOHNOT> select sdo_geom.validate_geometry_with_context(geometry, 0.0005) as geom_validate
2 from assessment_parcel_merged;
GEOM_VALIDATE
13033
1 row selected.
jot_test@JOHNOT>
jot_test@JOHNOT> set null null
jot_test@JOHNOT> select o.x, o.y
2 from assessment_parcel_merged a, table(sdo_util.getvertices(a.geometry)) o
3 where a.id = 506833;
X Y
632941.37 5536245.01
632939.952 5536241.98
633251.021 5536096.38
633369.443 5536040.96
633371.027 5536043.92
632941.37 5536245.01
631892.062 5536736.13
631892.884 5536702.62
632873.475 5536243.67
632884.74 5536267.82
632886.158 5536270.86
631892.062 5536736.13
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
null null
50 rows selected.John -
Problems with Multi-Polygon and creating index on it
I have a multipolygon that was created from a SDO_AGGR_UNION and I'm trying to create an index on the geometry. It is failing with...
ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
ORA-13249: internal error in Spatial index: [mdidxrbd]
ORA-13249: Error in Spatial index: index build failed
ORA-13249: Error in spatial index: [mdrcrtxfergm]
ORA-13249: Error in spatial index: [mdpridxtxfergm]
ORA-13200: internal error [ROWID:AAAW8+AAxAAAWdqAAA] in spatial indexing.
ORA-13206: internal error [] while creating the spatial index
ORA-13033: Invalid data in the SDO_ELEM_INFO_ARRAY in SDO_GEOMETRY object
ORA-06512: at "MDSYS
I'm beginning to think it's an issue with Oracle 9.2.0.1 which is the version of database we are using. Just want to check to see if others have had problems with this.
Here is the geometry of the object.
mdsys.sdo_geometry(2007, 900001, NULL, mdsys.sdo_elem_info_array(1, 1003, 1, 125, 1003, 1, 489, 1003, 1, 739, 1003, 1, 825, 1003, 1, 941, 1003, 1, 1209, 1003, 1, 1237, 1003, 1, 1369, 1003, 1, 1511, 1003, 1, 1551, 1003, 1, 1727, 1003, 1, 2445, 1003, 1, 2547, 1003, 1, 3829, 1003, 1, 3937, 1003, 1, 4085, 1003, 1, 4095, 1003, 1, 4583, 1003, 1, 6149, 1003, 1, 6379, 1003, 1, 6433, 1003, 1, 6465, 1003, 1, 6485, 1003, 1, 6559, 1003, 1, 6577, 1003, 1, 6607, 1003, 1, 6773, 1003, 1, 6793, 1003, 1, 6807, 1003, 1, 6825, 1003, 1, 6833, 1003, 1, 6855, 1003, 1, 6885), mdsys.sdo_ordinate_array(235180.1, 1269688.5, 235179.9, 1269684.4, 235180.6, 1269680.3, 235182.1, 1269676.7, 235184.2, 1269673.3, 235187, 1269670.4, 235190.3, 1269668.1, 235194, 1269666.5, 235197.8, 1269665.6, 235200.8, 1269665.5, 235205.5, 1269666.8, 235230.8, 1269673.6, 235242.3, 1269676.5, 235261.8, 1269681.2, 235270.1, 1269683.2, 235281, 1269685.6, 235296.1, 1269689, 235335.7, 1269696.8, 235368.9, 1269702.5, 235372.8, 1269703.5, 235376.4, 1269705.4, 235379.5, 1269707.8, 235382.2, 1269710.9, 235384.1, 1269714.5, 235385.3, 1269718.3, 235385.7, 1269722.6, 235385.4, 1269726.3, 235384.2, 1269730.2, 235382.3, 1269733.7, 235379.9, 1269736.7, 235370.9, 1269745.9, 235357.1, 1269760.7, 235342.1, 1269778.7, 235332.3, 1269791.1, 235323.8, 1269802.8, 235320.4, 1269807.5, 235313.4, 1269818, 235309.4, 1269824, 235307.2, 1269827.6, 235304.5, 1269830.5, 235301.3, 1269832.8, 235297.7, 1269834.3, 235293.9, 1269835.2, 235289.8, 1269835.2, 235286.1, 1269834.4, 235282.4, 1269832.9, 235279.1, 1269830.6, 235278.1, 1269829.8, 235276.2, 1269825.5, 235274, 1269820.9))The elem_info_array for the multi-polygon is obviosuly wrong:
mdsys.sdo_elem_info_array(1, 1003, 1, 125, 1003, 1, 489, 1003, 1, 739, 1003, 1, 825, 1003, 1, 941, 1003, 1, 1209, 1003, 1, 1237, 1003, 1, 1369, 1003, 1, 1511, 1003, 1, 1551, 1003, 1, 1727, 1003, 1, 2445, 1003, 1, 2547, 1003, 1, 3829, 1003, 1, 3937, 1003, 1, 4085, 1003, 1, 4095, 1003, 1, 4583, 1003, 1, 6149, 1003, 1, 6379, 1003, 1, 6433, 1003, 1, 6465, 1003, 1, 6485, 1003, 1, 6559, 1003, 1, 6577, 1003, 1, 6607, 1003, 1, 6773, 1003, 1, 6793, 1003, 1, 6807, 1003, 1, 6825, 1003, 1, 6833, 1003, 1, 6855, 1003, 1, 6885)
The last entry should be something like: 6885,1003,1; instead it is just 6885.
So the problem might be with sdo_aggr_union as it seems to be creating an invalid geometry.
Can you post the data you used in generating this geometry with sdo_aggr_union ?
siva -
How to use java to store Multipolygon
I fell victim to the ORA-00939 problem of too many arguments when inserting a geometry object into the database, and found details on the forum to use java to insert it instead. The code located was:
double[] coords = new double[10000];
for(int i=0; i<coords.length; i++)
coords[i] = ....;
JGeometry mypoly = JGeometry.createLinearPolygon(coords, 2/*dimensions*/, 8256);
PreparedStatement ps = connection.prepareStatement("insert into states values(?)");
//convert JGeometry instance to DB STRUCT
STRUCT obj = JGeometry.store(mypoly, connection);
ps.setObject(1, obj);
ps.execute();
The SDO_GEOMETRY I want to insert is of SDO_GTYPE 2007 (collection of polygons) [in the example below, 2]
I can see in the sample code where to put the SRID (8307), but nowhere in the code, and nowhere in the Geometry class where I can create a multipolygon.
Anyone care to help with this?
As a secondary question: Some of the sites I'm updating have a boundary delineated by one polygon, some by more than one - can SDO_GTYPE 2007 be used for all, regardless of how many there are?
UPDATE LOC SET SITE_BOUNDARY=MDSYS.SDO_GEOMETRY(
2007,
8307,
SDO_POINT_TYPE(60.49772542, -1.452049075, NULL),
MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1, 105,1003,1),
MDSYS.SDO_ORDINATE_ARRAY(50.49678550013553,-7.217321117344117, ... <trimmed, you don't want to see it all>...)
WHERE SITECODE='970A3';This didn't work for me, but it got me close. I kept getting a null pointer exception on JGeometry.closeCoord when I used Object[]. Didn't matter if I made sure to close my rings or not. (The API docs suggest it will do this for you.)
Nonethelss, the following example does work:
double[] poly1 = {50,100, 51,101, 52,102, 53,103, 54,104};
double[] poly2 = {60,110, 61,111, 62,112, 63,113};
double[][] jpoly = {poly1, poly2};
JGeometry jgeom = JGeometry.createLinearPolygon(jpoly, 2, 8307);
The first array of doubles contains the x,y points seqentially. {x1,y1, x2,y2, x3,y3, ...}
Then you just have an array of the array of doubles. One for each polygon in the multipolygon.
Then, as luc said above, make sure you set the type correctly for multi or single polygon.
jgeom.setType( JGeometry.GTYPE_MULTIPOLYGON );
-or-
jgeom.setType( JGeometry.GTYPE_POLYGON );
I tested this using the sdoapi.jar from my Oracle 11.2.0.1 install, so I'm pretty sure I'm up to date.
Hope that helps somebody else.
-C. -
Using OFFLINE_INSTANTIATION with a spatial object - SDO_GEOMETRY type
Hello
I am looking for guidance on the usage of DBMS_REPCAT_RGT.INSTANTIATE_OFFLINE for a table object with an SDO_GEOMETRY
column defined.
The table is:
SQL> descr jtx.jtx_jobs_aoi
Name Null? Type
OBJECTID NOT NULL NUMBER(38)
JOB_ID NUMBER(10)
SHAPE MDSYS.SDO_GEOMETRY
SE_ANNO_CAD_DATA BLOB
The mview is defined as:
CREATE MATERIALIZED VIEW jtx.JTX_JOBS_AOI REFRESH FAST WITH PRIMARY KEY FOR UPDATE AS
SELECT * FROM JTX.JTX_JOBS_AOI@ncgsdb_master_s;
And the command we are using is:
SQL> SET SERVEROUTPUT ON
SQL>
SQL> DECLARE
2 dt_num NUMBER;
3 BEGIN
4 dt_num := DBMS_REPCAT_RGT.INSTANTIATE_OFFLINE(
5 refresh_template_name => 'jtx_refg_dt',
6 user_name => 'jtx',
7 site_name => 'NCGSDB_MVSITE1',
8 next_date => SYSDATE,
9 interval => 'SYSDATE + (1/96)');
10 DBMS_OUTPUT.PUT_LINE('Template ID = ' || dt_num);
11 END;
12 /
When we run this on an 11.1.0.6 database we get:
DECLARE
ERROR at line 1:
ORA-30373: object data types are not supported in this context
ORA-06512: at "SYS.DBMS_REPCAT_RGT_CUST", line 1991
ORA-06512: at "SYS.DBMS_REPCAT_RGT", line 1330
ORA-06512: at line 4
Now the strange thing is this appears to work for ONLINE_INSTANTIATION.
1. Is this supported?
2. If so what are we doing wrong?
Thanks
RichardHere a full example with CAST MULTISET as @PhilHerring wrote and with CAST COLLECT using the simplest possible function make_geometry:
CREATE OR REPLACE TYPE t_sdo_geometries AS TABLE OF MDSYS.sdo_geometry;
CREATE OR REPLACE FUNCTION make_geometry (p_points t_sdo_geometries)
RETURN t_sdo_geometries IS
BEGIN
RETURN p_points;
END;
SELECT make_geometry (
t_sdo_geometries (
sdo_geometry(2001, 32774, sdo_point_type(1, 1, null), null, null),
sdo_geometry(2001, 32774, sdo_point_type(2, 2, null), null, null),
sdo_geometry(2001, 32774, sdo_point_type(3, 3, null), null, null),
sdo_geometry(2001, 32774, sdo_point_type(4, 4, null), null, null)))
AS geom
FROM DUAL;
WITH geoms(pcol) AS
(SELECT sdo_geometry(2001, 32774, sdo_point_type(1, 1, null), null, null) FROM dual UNION ALL
SELECT sdo_geometry(2001, 32774, sdo_point_type(2, 2, null), null, null) FROM dual UNION ALL
SELECT sdo_geometry(2001, 32774, sdo_point_type(3, 3, null), null, null) FROM dual UNION ALL
SELECT sdo_geometry(2001, 32774, sdo_point_type(4, 4, null), null, null) FROM dual)
SELECT make_geometry(cast(multiset(select pcol from geoms a) as t_sdo_geometries)) FROM dual;
WITH geoms(pcol) AS
(SELECT sdo_geometry(2001, 32774, sdo_point_type(1, 1, null), null, null) FROM dual UNION ALL
SELECT sdo_geometry(2001, 32774, sdo_point_type(2, 2, null), null, null) FROM dual UNION ALL
SELECT sdo_geometry(2001, 32774, sdo_point_type(3, 3, null), null, null) FROM dual UNION ALL
SELECT sdo_geometry(2001, 32774, sdo_point_type(4, 4, null), null, null) FROM dual)
SELECT make_geometry(cast(collect(pcol) as t_sdo_geometries)) FROM geoms;
Hope that helps
_jum -
More than one SDO_GEOMETRY columns in one Oracle 8i spatial table
I have a spatial table as follows:
CREATE TABLE TEST(
ID VARCHAR2(255) NOT NULL,
POINT MDSYS.SDO_GEOMETRY,
LINE MDSYS.SDO_GEOMETRY,
POLYGON MDSYS.SDO_GEOMETRY,
PRIMARY KEY(ID));
Is it a good practice to have more than one SDO_GEOMETRY columns
in one spatial table? What are the drawbacks if any to have a
spatial with more than one layer?I have one question about more than one SDO_GEOMETRY columns
in one table in Oracle 8.1.7. When I wanted to create two
spatial indices for this table, every time I got some error.
Can anyone tell me how to figure it out?
Thanks very much,
Fan Fan,
You need to insert metadata record before creating spatial
indices.
Try the following:
REM USER_SDO_GEOM_METADATA :
REM insert a row for the geom layer for TEST TEST2 tables
REM
INSERT INTO USER_SDO_GEOM_METADATA
( TABLE_NAME, COLUMN_NAME, DIMINFO, SRID)
VALUES ('TEST', 'POINT', MDSYS.SDO_DIM_ARRAY
(MDSYS.SDO_DIM_ELEMENT('LON', -180,
180, .000005),MDSYS.SDO_DIM_ELEMENT('LAT', -90, 90, .000005)),
NULL);
INSERT INTO USER_SDO_GEOM_METADATA
( TABLE_NAME, COLUMN_NAME, DIMINFO, SRID)
VALUES ('TEST', 'LINE', MDSYS.SDO_DIM_ARRAY
(MDSYS.SDO_DIM_ELEMENT('LON', -180,
180, .000005),MDSYS.SDO_DIM_ELEMENT('LAT', -90, 90, .000005)),
NULL);
INSERT INTO USER_SDO_GEOM_METADATA
( TABLE_NAME, COLUMN_NAME, DIMINFO, SRID)
VALUES ('TEST', 'POLYGON', MDSYS.SDO_DIM_ARRAY
(MDSYS.SDO_DIM_ELEMENT('LON', -180,
180, .000005),MDSYS.SDO_DIM_ELEMENT('LAT', -90, 90, .000005)),
NULL);
REM create a spatial index based on TRAFFIC.GEOM
REM
REM
CREATE INDEX TEST_G_POINT_IDX ON TEST(POINT) INDEXTYPE IS
MDSYS.SPATIAL_INDEX;
CREATE INDEX TEST_G_LINE_IDX ON TEST(LINE) INDEXTYPE IS
MDSYS.SPATIAL_INDEX;
CREATE INDEX TEST_G_POLYGON_IDX ON TEST(POLYGON) INDEXTYPE IS
MDSYS.SPATIAL_INDEX; -
4.0EA3 BUG: Database copy of a SDO_GEOMETRY column fails
I'm trying to copy a table that has a SDO_GEOMETRY column and it just fails:
When copying a error message appears:
Error occurred inserting data for TABLE: CLIENT_LOCATION. Batch 1 containing 500 rows failed.
ORA-00932: inconsistent datatypes: expected MDSYS.SDO_GEOMETRY got CHAR
The problem seems to be present also in sql developer 3.2.20.09: https://forums.oracle.com/message/11001171It's still a bug. Limitation in the JDBC driver and user defined types is causing the issue.
-
How to insert Sdo_Geometry from VB
Hi,
I have some queries for you guys. After trying several times, I still cannot make it work.
Here is the scenario:
I am retrieving a Polygon object from Oracle Spatial DB and I wanted to insert it into another Spatial Database.
I am using the Oracle Object for OLE (OO4O). The Polygons contain attributes as well. I intend to insert
the Attributes and the Geometries at the same time.
Please find my code below for your reference.
Public Function ConnectToOracle(sDBName As String, sUserAndPassword As String) As OraDatabase
Dim OraSession As OraSession
Dim OraDatabase As OraDatabase
Set OraSession = CreateObject("OracleInProcServer.XOraSession")
Set OraDatabase = OraSession.OpenDatabase(sDBName, sUserAndPassword, ORADB_DEFAULT)
Set ConnectToOracle = OraDatabase
End Function
Public Function RetrieveRecord(sBldgID As String) As String
Dim oraDB As OraDatabase
Dim DS As OraDynaset
Dim Ordinates As OraCollection
Dim sdo_geometry As OraObject
Dim sql As String
Dim sGeom As String
Dim sBldg_ID As String, sMainBldg_ID As String, sEstate_ID As String, sCat_ID As String, sBldg_Type As String, sCat_Type As String
Dim sStatCode As String, sName As String, sMRC As String
Dim DteCreate, DteDelete, dteUpdate
Dim sAttributes As String
Set oraDB = ConnectToOracle("service1", "user1/pwd1")
sql = "select a.bldg_id,a.main_bldg_id,a.estate_id,a.cat_bldg_id,a.bldg_type, " & _
"a.cat_type,a.bldg_type,a.status_code,a.name,a.centroid_mrc, a.dte_create,a.dte_delete, " & _
"a.dte_update, b.geometry from bldg a, bldg_geom b where a.bldg_id='" & sBldgID & "' and b.bldg_id=' " & sBldgID & "'"
Set DS = oraDB.CreateDynaset(sql, ORADB_DEFAULT)
If Not DS.EOF Then
Set sdo_geometry = DS.Fields("geometry").Value
If Not IsNull(sdo_geometry.Item("sdo_ordinates").Value) Then
Set Ordinates = sdo_geometry.Item("sdo_ordinates").Value
sBldg_ID = DS.Fields("bldg_id").Value
sMainBldg_ID = DS.Fields("main_bldg_id").Value
sEstate_ID = IIf(IsNull(DS.Fields("estate_id").Value), """", DS.Fields("estate_id").Value)
sCat_ID = DS.Fields("cat_bldg_id").Value
sBldg_Type = DS.Fields("bldg_type").Value
sCat_Type = DS.Fields("cat_type").Value
sStatCode = DS.Fields("status_code").Value
sName = DS.Fields("name").Value
sMRC = DS.Fields("centroid_mrc").Value
DteCreate = CDate(DS.Fields("dte_create").Value)
If (IsNull(DS.Fields("dte_delete").Value)) Then
DteDelete = DateTime.Date
Else
DteDelete = CDate(DS.Fields("dte_delete").Value)
End If
If (IsNull(DS.Fields("dte_update").Value)) Then
dteUpdate = DateTime.Date
Else
dteUpdate = CDate(DS.Fields("dte_update").Value)
End If
Else
MsgBox "No geometry!"
End If
' Concatenate all the Geometries separated by comma
For i = 1 To Ordinates.Size
If i = 1 Then
sGeom = Ordinates(i)
Else
sGeom = sGeom & "," & Ordinates(i)
End If
Next i
sAttributes = "'" & sBldg_ID & "','" & sMainBldg_ID & "','" & sEstate_ID & "','" & sCat_ID & "','" & sBldg_Type & "','" & _
sCat_Type & "','" & sStatCode & "','" & sName & "','" & sMRC & "','" & _
DteCreate & "','" & DteDelete & "','" & dteUpdate & "'"
End If
DS.Close
Set DS = Nothing
Call InsertSingleRecord(sAttributes, sGeom)
End Function
Public Function InsertSingleRecord(sAttributes As String, sGeometry As String)
Dim oraDB As OraDatabase
Dim sql As String
Set oraDB = ConnectToOracle("service2", "user2/pwd2")
sql = "Insert into bldg(bldg_id,main_bldg_id,estate_id,cat_bldg_id,bldg_type,cat_type,status_code,name,centroid_mrc,geom) " & _
"values ( " & sAttributes & ", " & _
"MDSYS.SDO_GEOMETRY ( " & _
"2003, NULL, NULL, " & _
"MDSYS.SDO_ELEM_INFO_ARRAY (1,1003,1), " & _
"MDSYS.SDO_ORDINATE_ARRAY ( " & sGeometry & " )" & _
oraDB.ExecuteSQL sql
oraDB.Close
Set oraDB = Nothing
End Function
After running this code, I successfully retrieved the data and able to manipulate it by concatenating them and stored in a variable to be inserted to database. During the insertion comes the problem, the error message is "ORA-00907: missing right parenthesis".
I tried to manually execute the SQL Statement in the SQL Plus and it gives me the same error message. My observation is that the SQL Plus truncates the statement at a certain length. By the way, I checked the length of the resulting SQL from VB and it gives me 3096 characters. I am not sure if there is a limitation on the SQL statement length.
I cannot figure out what's wrong with this code. I hope you can help me.
I would appreciate any feedback from you guys and thank you in advance.
Best Regards,
Arnold Higuit
SingaporeHi Daniel,
Thank you for your reply. Here is the SQL Statement that was stored in the variable. I extracted this statement from the immediate window of VB IDE while debugging the code.
Insert into bldg(bldg_id,main_bldg_id,estate_id,cat_bldg_id,bldg_type,cat_type,status_code,name,centroid_mrc,geom) values ( 'P0750109270947202318','P0750109270947202318','"','P0750109270947202318','BT6','GO1','SC2','Istana','19489D8262', MDSYS.SDO_GEOMETRY ( 2003, NULL, NULL, MDSYS.SDO_ELEM_INFO_ARRAY (1,1003,1), MDSYS.SDO_ORDINATE_ARRAY ( 103.843218549901','1.30748186974166','103.843111698469','1.30753323638373','103.843175054448','1.3076666268715','103.843218549901','1.3076457365646','103.843286364106','1.30761206827051','103.843309190232','1.30765384888431','103.84336940088','1.30762445775988','103.84334855182','1.30758014498768','103.843450820054','1.30752724096372','103.843387104607','1.30739810088471','103.843380274743','1.30740307476731','103.843372007012','1.30738697747455','103.843413076066','1.30736617760188','103.843373624612','1.30728487723001','103.843367873147','1.30728704765151','103.843359875016','1.30727303034601','103.843375601678','1.30726724255536','103.84337901661','1.30727167383258','10
3.84338998034','1.30726751385805','103.843385846475','1.30725919390898','103.843432397393','1.30723839403631','103.843426915528','1.30722446716504','103.843435183259','1.30722030719051','103.843425657395','1.30719525690908','103.843437969125','1.30718838390768','103.843401033936','1.30711097220766','103.843384408608','1.30711802607752','103.843328781159','1.30699919550062','103.843419097131','1.30695343578075','103.843372725945','1.30686028852489','103.843282409974','1.30690604824476','103.84322372706','1.3067892072209','103.843234466425','1.30678423766741','103.843218549901','1.30675736008999','103.84319024191','1.30670124147699','103.843174515249','1.30670929012337','103.84316058592','1.30668188855198','103.843135692861','1.30669454934404','103.843128323797','1.30667998943317','103.843023898763','1.30673343606251','103.843030908361','1.306747453368','103.843003229437','1.30676165154195','103.843015720899','1.3067864305207','103.843003499037','1.3067926704825','103.843040973425','1.30686709785296','103.8430
19495298','1.3068781308289','103.843067214483','1.30697272503243','103.843021292631','1.30699614749774','103.843012935034','1.30697959803383','103.842944995855','1.30701432477776','103.842937716658','1.30699985530112','103.842849647353','1.30704480111293','103.842855129217','1.30705565322041','103.842784314307','1.30709191734624','103.842804290778','1.30713151608386','103.842819395053','1.3071608264333','103.842755284935','1.30718898377967','103.842727570789','1.30713392035982','103.842402269693','1.30729272579281','103.842486918126','1.30745403780143','103.842796133371','1.30730154741566','103.842762964268','1.30723686242187','103.842840463056','1.30720170959418','103.842874899878','1.30726853539547','103.842937447058','1.30723787819184','103.842943827589','1.30725099115504','103.843037468626','1.30720496013248','103.843030728628','1.30719085239276','103.843098667806','1.30715757259649','103.843094623807','1.30714916221319','103.843139377393','1.30712691539286','103.843187006711','1.30721762092454','103.843
218549901','1.30720498324404','103.84322585379','1.30720205696391','103.843278414575','1.30731373992449','103.843285873506','1.30730731909423','103.843297196702','1.30733381632332','103.843290906038','1.30733589631059','103.843326313493','1.30741005237836','103.843336378556','1.30740326981119','103.843341860421','1.30741855319589','103.843218549901','1.30748121514446 )) )
The error message is:
Run-time error '440':
SQL Execution error, 0RA-00907: missing right parenthesis
And here is the equivalent statement and error in SQL Plus after I copied and pasted the code.
SQL> Insert into bldg(bldg_id,main_bldg_id,estate_id,cat_bldg_id,bldg_type,cat_type,status_code,name
,centroid_mrc,geom)
2 values ('P0750109270947202318','P0750109270947202318','"','P0750109270947202318','BT6','GO1','S
C2','Istana','19489D8262',
3 MDSYS.SDO_GEOMETRY ( 2003, NULL, NULL, MDSYS.SDO_ELEM_INFO_ARRAY (1,1003,1), MDSYS.SDO_ORDINATE
_ARRAY ( 103.843218549901,1.30748186974166,103.843111698469,1.30753323638373,103.843175054448,1.3076
666268715,103.843218549901,1.3076457365646,103.843286364106,1.30761206827051,103.843309190232,1.3076
5384888431,103.84336940088,1.30762445775988,103.84334855182,1.30758014498768,103.843450820054,1.3075
2724096372,103.843387104607,1.30739810088471,103.843380274743,1.30740307476731,103.843372007012,1.30
738697747455,103.843413076066,1.30736617760188,103.843373624612,1.30728487723001,103.843367873147,1.
30728704765151,103.843359875016,1.30727303034601,103.843375601678,1.30726724255536,103.84337901661,1
.30727167383258,10
4 3.84338998034,1.30726751385805,103.843385846475,1.30725919390898,103.843432397393,1.30723839403
631,103.843426915528,1.30722446716504,103.843435183259,1.30722030719051,103.843425657395,1.307195256
90908,103.843437969125,1.30718838390768,103.843401033936,1.30711097220766,103.843384408608,1.3071180
2607752,103.843328781159,1.30699919550062,103.843419097131,1.30695343578075,103.843372725945,1.30686
028852489,103.843282409974,1.30690604824476,103.84322372706,1.3067892072209,103.843234466425,1.30678
423766741,103.843218549901,1.30675736008999,103.84319024191,1.30670124147699,103.843174515249,1.3067
0929012337,103.84316058592,1.30668188855198,103.843135692861,1.30669454934404,103.843128323797,1.306
67998943317,103.843023898763,1.30673343606251,103.843030908361,1.306747453368,103.843003229437,1.306
76165154195,103.843015720899,1.3067864305207,103.843003499037,1.3067926704825,103.843040973425,1.306
86709785296,103.8430
5 19495298,1.3068781308289,103.843067214483,1.30697272503243,103.843021292631,1.30699614749774,10
3.843012935034,1.30697959803383,103.842944995855,1.30701432477776,103.842937716658,1.30699985530112,
103.842849647353,1.30704480111293,103.842855129217,1.30705565322041,103.842784314307,1.3070919173462
4,103.842804290778,1.30713151608386,103.842819395053,1.3071608264333,103.842755284935,1.307188983779
67,103.842727570789,1.30713392035982,103.842402269693,1.30729272579281,103.842486918126,1.3074540378
0143,103.842796133371,1.30730154741566,103.842762964268,1.30723686242187,103.842840463056,1.30720170
959418,103.842874899878,1.30726853539547,103.842937447058,1.30723787819184,103.842943827589,1.307250
99115504,103.843037468626,1.30720496013248,103.843030728628,1.30719085239276,103.843098667806,1.3071
5757259649,103.843094623807,1.30714916221319,103.843139377393,1.30712691539286,103.843187006711,1.30
721762092454,103.843
6 218549901,1.30720498324404,103.84322585379,1.30720205696391,103.843278414575,1.30731373992449,1
03.843285873506,1.30730731909423,103.843297196702,1.30733381632332,103.843290906038,1.30733589631059
,103.843326313493,1.30741005237836,103.843336378556,1.30740326981119,103.843341860421,1.307418553195
89,103.843218549901,1.30748121514446 )) )
7
SQL> /
3.84338998034,1.30726751385805,103.843385846475,1.30725919390898,103.843432397393,1.30723839403631,1
ERROR at line 4:
ORA-00907: missing right parenthesis
We are actually dealing with large polygons and this one is just an example of a building outline.
The other objects we have are Boundaries and Islands. I am worried about the 999 ordinates limitation. I can just hope that our largest Boundary would not reach that number.
I hope you can spot the problem. Once again many thanks.
Best Regards,
Arnold -
How can i return a SDO_GEOMETRY value in a Java-Stored-Function?
For a example, Ive got a java-function witch returns a
oracle.sdoapi.geom.Geometry like:
public static Geometry GetQPoint(String sF_TABLE_NAME, long lFID)
And now, Ill try to deploy this function as a PL-SQL stored-function like:
GET_Q_POINT(
F_TABLE_NAME IN VARCHAR2,
FID IN NUMBER
) RETURN MDSYS.SDO_GEOMETRY;
I can't deploy this above mentioned java-function with Oracle9i JDeveloper because oracle.sdoapi.geom.Geometry can not mapped in any PL-SQL data type.
Is there any possibility to do it in a other way?
Please help me.a quick example that takes as input a longitude and latitude,
and return a point geometry in wgs 84:
CREATE OR REPLACE FUNCTION get_geom (
longitude IN NUMBER,
latitude IN NUMBER )
RETURN mdsys.sdo_geometry
DETERMINISTIC IS
BEGIN
RETURN mdsys.sdo_geometry (2001,8307,
mdsys.sdo_point_type (longitude, latitude, NULL), NULL, NULL );
END;
other pl/sql examples:
REM
REM This function doesn't really do anything, but demonstrates some simple
REM mechanisms on how to manipulate the array portion of the geometry object, and
REM also how to write a function that returns a geometry object.
REM
REM The function demonstrates:
REM 1) .EXTEND (there is also .DELETE)
REM 2) .COUNT
REM 3) Any function that returns an object (including the SDO_GEOMETRY object)
REM should be declared as DETERMINSTIC (see below).
REM
create or replace function create_geometry return mdsys.sdo_geometry deterministic as
temp_geom mdsys.sdo_geometry := mdsys.sdo_geometry (2002, 8307, null,
mdsys.sdo_elem_info_array (1,2,1),
mdsys.sdo_ordinate_array ());
begin
for i in 1 .. 10 loop
temp_geom.sdo_ordinates.extend (2);
temp_geom.sdo_ordinates(temp_geom.sdo_ordinates.count-1) := i;
temp_geom.sdo_ordinates(temp_geom.sdo_ordinates.count) := i+1;
end loop;
return temp_geom;
end;
select create_geometry from dual;
set linesize 80
set pages 1000
drop table TEST_MODIFY;
create table TEST_MODIFY (geom mdsys.sdo_geometry);
insert into TEST_MODIFY values
(mdsys.sdo_geometry (2002, 8307, null,
mdsys.sdo_elem_info_array (1,2,1),
mdsys.sdo_ordinate_array (1,1, 2,2, 3,3, 4,4)));
insert into TEST_MODIFY values
(mdsys.sdo_geometry (2002, 8307, null,
mdsys.sdo_elem_info_array (1,2,1),
mdsys.sdo_ordinate_array (21,21, 22,22, 23,23, 24,24)));
REM
REM Select values before update.
REM
select geom from TEST_MODIFY;
REM
REM This PL*SQL block updates all the ordinates of a geometry by adding 10 to each x value
REM and 20 to each y value.
REM
declare
i NUMBER;
cursor c1 is select geom, rowid
from TEST_MODIFY;
begin
for r in c1 loop
i := 1;
while (i < r.geom.sdo_ordinates.count) loop
r.geom.sdo_ordinates(i) := r.geom.sdo_ordinates(i) + 10;
r.geom.sdo_ordinates(i+1) := r.geom.sdo_ordinates(i+1) + 20;
i := i + 2;
end loop;
update TEST_MODIFY set geom = r.geom where rowid = r.rowid;
end loop;
end;
REM
REM Select values after update.
REM
select geom from TEST_MODIFY; -
Extracting x,y co-ordinates of SDO_GEOMETRY into two variables say x1, ya
Hi All,
I am able to store the output SDO_GEOMETRY into a variable but i am facing difficulties in extracting ordinates in sdo_geometry to two independent variables say xa, ya. Kindly suggest some solution.
The procedure is as follows:
CREATE OR REPLACE PROCEDURE fnd_2nd_Point
(Input_Fiber_Id IN NUMBER,
xa IN FLOAT,
ya IN FLOAT,
Length_Fiber IN FLOAT,
Result OUT VARCHAR,
xCordInAte OUT FLOAT,
yCordInAte OUT FLOAT)
IS
ProjPoint_a mdsys.sDo_Geometry := NULL;
v_Point_xa FLOAT := NULL;
v_Point_ya FLOAT := NULL;
BEGIN
SELECT sDo_lrs.Project_pt(a.Shape,m.DimInfo,mdsys.Sdo_geometry(2001,8307,NULL,mdsys.Sdo_elem_info_array(1,1,1),
mdsys.Sdo_ordinate_array(xa,ya,Length_Fiber)))
INTO {color:#0000ff}ProjPoint_a
{color}FROM lrs_Access_Fiber a,
User_sDo_geom_MetAdAta m
WHERE m.Table_Name = 'LRS_ACCESS_FIBER'
AND m.Column_Name = 'SHAPE'
AND a.Unique_Id = Input_Fiber_Id;
{color:#0000ff}-- SELECT t.x, t.y INTO v_Point_xa, v_Point_ya FROM TABLE(sDo_util.Getvertices(ProjPoint_a)) t;
{color}
{color:#0000ff}-- dbms_Output.Put_Line('Point Xa is ' ||v_Point_xa||' and point Ya is '||v_Point_ya);
{color}
{color:#0000ff}-- xCordInAte := v_Point_xa;
{color}
{color:#0000ff}-- yCordInAte := v_Point_ya;
{color}
-- Result := 'success';
END;
Kindly advice on the options available to extract the ordinates of sdo_geometry into 2 independent variables.
Regards,
VenkatPlease find the output as below for the following inputs: INPUT_FIBER_ID :=2005; XA := 78.424; YA := 17.643; LENGTH_FIBER :=500;
Point Xa is 78.48686988 and point Ya is 17.61674904
RESULT = success
XCORDINATE = 78.48686988
YCORDINATE = 17.61674904
Is this output correct? Actually, I have to integrate this with UMN MapServer. Kindly advice
Regards
Venkat -
How to get the x1,y1 and z1 coordinates out of an sdo_geometry object?
Hello,
i have stored several boxes into an sdo_geometry object like the following:
mdsys.sdo_geometry(3003,null,null,
mdsys.sdo_elem_info_array(1,1003,3),
mdsys.sdo_ordinate_array(x1,y1,z1,x2,y2,z2)
now i would like to get the x1,y1,z1 coordinates from the boxes. how can i get them with a simple sql-statement?
When i do "SELECT v.shape.sdo_ordinates ..." then i get a sdo_ordinate_array. But how can i get only the first coorinates?
I know how it works to get x1,y1 and z1 over a java-prog. But i want to get them with a sql-statement as i also want to get the min and max x1,y1,z1.
Hope there is anybody that can help me. Thanks in advance.
Markus VeithYou can get coordinates from an SDO_POINT_TYPE as follows:
SELECT t.GEOMETRY.SDO_POINT.x,t.GEOMETRY.SDO_POINT.y
FROM TABLE T
(where geometry is the geometry column and table is the geometry table, note
that a table alias must be used.)
Getting the coordinates from the SDO_ORDINATES is a little trickier.
You'll need to use a loop in PL/SQL, eg:
SET SERVEROUT ON
DECLARE
i number;
j NUMBER;
BEGIN
FOR sel IN (SELECT <geom_column> FROM <geom_table> WHERE ROWNUM < 10) LOOP
i := 1;
while i < sel.<geom_column>.sdo_ordinates.count LOOP
j:= sel.GEOMETRY.sdo_ordinates(i);
dbms_output.put_line(j);
i := i + 1;
j:= sel.GEOMETRY.sdo_ordinates(i);
end loop;
dbms_output.put_line(j);
END LOOP;
END;
This will print the SDO_ORDINATES to the SQLPLUS screen, put a WHERE clause to reduce output.
To use these values in a query, put them in a cursor. -
How to define SDO_GEOMETRY
Hello,
I created an Oracle Object Type named MDSYS.SDO_GEOMETRY (no Attributes). Then I defined on table "COUNTIES" a column named "GEOMETRY" with this data type.
While trying to generate the table into the database I run into:
CDS-11349 Warning: The Oracle Object Type MDSYS.SDO_GEOMETRY cannot be generated.
CDS-18025 Error: Table 'COUNTIES' will not be created as Oracle Object Type 'MDSYS.SDO_GEOMETRY' is not created
Processing Complete: 1 error(s), 1 warning(s)
How can SDO_GEOMETRY types be defined?
Thanks JanHello Jan
We have stored it as follows:
- create three oracle object types (in the server tab of the DE) with the names SDO_POINT_TYPE, SDO_DIM_ELEMENT and MDSYS.SDO_GEOMETRY
- create attributes for SDO_POINT_TYPE: X, Y and Z, all the datatype NUMBER
- create attributes for SDO_DIM_ELEMENT: SDO_LB, SDO_UB, SDO_TOLERANCE (all 3 NUMBER) and SDO_DIMNAME (VARCHAR2(64))
- create 3 oracle collection types:
--- MDSYS.SDO_DIM_ARRAY (object datatype SDO_DIM_ELEMENT, the one we have just created)
--- MDSYS.SDO_ELEM_INFO_ARRAY (scalar datatype NUMBER)
--- MDSYS.SDO_ORDINATE_ARRAY(scalar datatype NUMBER)
- create attributes for MDSYS.SDO_GEOMETRY:
--- SDO_ELEM_INFO based on oracle type MDSYS.SDO_ELEM_INFO_ARRAY
--- SDO_ORDINATES, based on oracle type MDSYS.SDO_ORDINATE_ARRAY
--- SDO_POINT, based on oracle type SDO_POINT_TYPE
--- SDO_GTYPE, based on datatype number
--- SDO_SRID, based on datatype number
Than the same, add it to a column in a table an this should do the trick...
good luck...
Alex
[email protected]
Maybe you are looking for
-
Why can I no longer install iTunes updates on my computer? I keep getting messages saying it fails, and to do it manually, but then I get popups questioning whether I have the authority to make these changes. And it never updates.
-
MacBook Pro Won't Boot after Firmware Update
So I just upgraded to a MacBook Pro which came in the mail yesterday. I removed the Apple-installed HD and swapped it out for a bigger, faster HD. I installed OS X from scratch, imported everything from my Time Machine backup during the Setup Assista
-
I am over capacity on my #GS iPhone and I have a very large amount of audio space that I think might be taken up by season one of Downton Abbey. I have tried to copy and save episodes to my external hard drive but I get a message saying I "don't hav
-
Video download/playback question
I just got a new MacBook, upgrading from a Powerbook G4. I have a subscription to a video website. The new computer downloaded wmv files right in Quicktime. I loaded some other software, and now the video plays in the safari winodw directly. I would
-
MiniDisc : Connect Digital or Analog for best transfer?
I'm not the Smithsonian or BBC, but I still want to preserve some demo tracks from a stereo Minidisc for the future. That is, if need to tweak the track later in 2010, be sure now in 2006, to have digitized it well enough. If connect digital via opti