"invalid LRS segment" when querying an Oracle Spatial DB

I have a table of GIS segments in an Oracle Spatial database. I'm using C# and ODP to connect to the database. For a given measure from the start of a segment, I want to find the GPS coordinates for that point. I'm running the following query:
select g.geom.sdo_ordinates ord_array from
*(select sdo_lrs.locate_pt(shape,0.02,0) as geom from test_schema.test_table*
where route='ABC' and segmentnum='101.1') g
where shape is of type SDO_GEOMETRY. I'm getting the following error:
ORA-13331: invalid LRS segment
Is there a problem with how I'm passing shape to locate_pt()? The Oracle Spatial documentation says the argument should be SDO_geometry, so that seems ok.
Edited by: 964844 on Oct 11, 2012 2:10 PM

I'm using C# with ODP.NET.
Here is the current version of the code that is failing:
var param = new OracleParameter("geom", OracleDbType.Object);
param.UdtTypeName = "MDSYS.SDO_GEOMETRY";
param.Direction = ParameterDirection.Input;
OracleCommand oCmd = new OracleCommand();
oCmd.Connection = this.oConn;
oCmd.CommandText = queryStr;
oCmd.CommandType = CommandType.Text;
oCmd.Parameters.Add(param);
OracleDataAdapter da = new OracleDataAdapter(oCmd);
DataTable dt = new DataTable();
da.Fill(dt);
The exception is generated by the da.Fill(dt) line.

Similar Messages

  • Basic query in Oracle Spatial

    I'm trying to learn Oracle Spatial working with 11g R2 and with 3D georeferenced data (specifically data describing buildings in a city).
    But I'm having trouble getting a basic query to work on my dataset (it works for the book example), and I'm trying to do it exactly the way it's done in the Spatial Developer's Guide for 11g.
    To learn how spatial queries work, I set up the cola_markets tables used in the book, made the appropriate manual entry in the user_sdo_geom_metadata view and created the index. Having done that, I can run the following simple query (as well as the others in the manual) on the book tables:
    SELECT SDO_GEOM.SDO_DISTANCE(c_b.shape, c_d.shape, 0.005)
    FROM cola_markets c_b, cola_markets c_d
    WHERE c_b.name = 'cola_b' AND c_d.name = 'cola_d';
    but when I try to do the same thing on my own tables (created from citygml data), I get an error. There is the difference that the data is 3D, and the index was created without any PARAMETERS ( ... ), hence is just 2D. But still I don't get why the following query doesn't work:
    SELECT SDO_GEOM.SDO_DISTANCE(c_w.envelope, c_b.envelope, 0.0005)
    FROM cityobject c_w,
         cityobject c_b
    WHERE c_w.id = 50025
         AND c_b.id = 50018;
    The id's for the buildings are valid, and I used the same tolerance used by the software that set up the database.
    Here's the error I get in SQL developer:
    ORA-29532: Java call terminated by uncaught Java exception: java.lang.Exception: 54535
    ORA-06512: at "MDSYS.SDO_3GL", line 637
    ORA-06512: at "MDSYS.SDO_GEOM", line 1973
    ORA-06512: at "MDSYS.SDO_GEOM", line 1990
    29532. 00000 - "Java call terminated by uncaught Java exception: %s"
    *Cause: A Java exception or error was signaled and could not be
         resolved by the Java code.
    *Action: Modify Java code, if this behavior is not intended.
    So, thinking it might have something to do with the fact that it's a Java interface, I also tried running it from SQL/PL command line and get essentially the same thing:
    ERROR at line 1:
    ORA-29532: Java call terminated by uncaught Java exception:
    java.lang.Exception: 54535
    ORA-06512: at "MDSYS.SDO_3GL", line 637
    ORA-06512: at "MDSYS.SDO_GEOM", line 1973
    ORA-06512: at "MDSYS.SDO_GEOM", line 1990
    Any ideas why this isn't working?
    (P.S.: I couldn't find a specific board for Oracle Spatial, hence put this question here--if there's a better place for this question, then, admins, of course, feel free to move the thread to the appropriate spot)

    Hi,
    The SPATIAL forum is here : {forum:id=76}

  • Query on Oracle Spatial Locational Analysis

    Hi,
    I am working on Oracle Spatial Locational Analysis.
    It was very interesting to see an example in this below mentioned URL.
    http://technet.oracle.com/products/oracle9i/htdocs/9iober2/obe9ir2/download/obe-cnt_spatial.zip
    The procedure mentioned is very clear but have some clarifications in between.
    After creating the tables customers and warehouses, there aren't any .sql files where the data is feeded in to these two tables. With out the above mentioned step, in the procedure it is told to execute loc_updates.sql which updates any of the rows since if you look at the syntax in loc_updates.sql file it shows update the table customers whose customer_id=344.
    Do we have to manually enetred the customer_id values?
    Did Oracle miss uploading any .sql files?
    I would very grateful if one could help me in this regard.
    Thanks and Regards,
    Nandakishore.

    Nice to have a EXPERT in this FORUM...!!
    Hi Dan, if you look at my reply I mentioned that I had loaded loc_updates.sql
    From my previous reply:
    execute loc_updates.sql which doenot update any of the rows since if you look at the syntax in loc_updates.sql file it shows update the table customers whose customer_id=344.
    Where is this customer_id=344 coming from?
    Also the datatype is a number.
    Dan, were you able to get the results as desired?
    or may be I am missing something...
    Thanks and Regards,
    Nandakishore.

  • Sdo_filter fail when query against a spatial view in different schema

    We have a table with X,Y coordinates and would like to run spatial query against it. We do not want to change the table structure, so we opt to use a function based index. USER_SDO_GEOM_METADATA is updated and index is built. Then we created a view with spatial column from the table. Everything works fine with the user who owns the table and view.
    When we try to run a spatial query against the view from a different user, it failed with error. However, if we substitute the select from my_view* with the actual SQL statement that created the view, it works. So it looks like Oracle refuse to acknowledge the spatial index if accessed via view. Here is some simplified scripts:
    --- connect as USER1.
    --update meta data
    INSERT INTO USER_SDO_GEOM_METADATA ( TABLE_NAME, COLUMN_NAME, DIMINFO, SRID ) VALUES
    ('LOCATIONS', 'MDSYS.SDO_GEOMETRY(2001,2264,SDO_POINT_TYPE(NVL(X_COORD,0),NVL(Y_COORD,0),NULL),NULL,NULL)',
    SDO_DIM_ARRAY( SDO_DIM_ELEMENT('X', 1300000, 1600000, 1), SDO_DIM_ELEMENT('Y', 400000, 700000, 1) ), 2264 );
    --created index
    CREATE INDEX LOCA_XYGEOM_IDX ON LOCATIONS
    ( SDO_GEOMETRY(2001,2264,SDO_POINT_TYPE(NVL(X_COORD,0),NVL(Y_COORD,0),NULL),NULL,NULL)
    ) INDEXTYPE IS MDSYS.SPATIAL_INDEX;
    --create view
    CREATE VIEW USER1.MY_VIEW AS SELECT ID ,X_COORD,Y_COORD, SDO_GEOMETRY(2001,2264,SDO_POINT_TYPE(NVL(X_COORD,0),NVL(Y_COORD,0),NULL),NULL,NULL) SHAPE
    FROM USER1.LOCATIONS WHERE X_COORD>0 AND Y_COORD>0;
    -- run spatial query from view, works fine by user1 by failed on user2.
    SELECT SHAPE FROM (
    SELECT * FROM USER1.MY_VIEW
    ) a WHERE sdo_filter (shape, sdo_geometry ('POLYGON ((1447000 540000, 1453000 540000, 1453000 545000, 1447000 545000, 1447000 540000))', 2264), 'querytype=window') = 'TRUE';
    -- run spatial query from table directly, simply replace the view with actual statements that created the view. works fine by user1 AND user2.
    SELECT SHAPE FROM (
    SELECT ID ,X_COORD,Y_COORD, SDO_GEOMETRY(2001,2264,SDO_POINT_TYPE(NVL(X_COORD,0),NVL(Y_COORD,0),NULL),NULL,NULL) SHAPE
    FROM USER1.LOCATIONS WHERE X_COORD>0 AND Y_COORD>0
    ) a WHERE sdo_filter (shape, sdo_geometry ('POLYGON ((1447000 540000, 1453000 540000, 1453000 545000, 1447000 545000, 1447000 540000))', 2264), 'querytype=window') = 'TRUE';
    When run against the view by user2, the error is:
    ORA-13226: interface not supported without a spatial index
    ORA-06512: at "MDSYS.MD", line 1723
    ORA-06512: at "MDSYS.MDERR", line 8
    ORA-06512: at "MDSYS.SDO_3GL", line 1173
    13226. 00000 - "interface not supported without a spatial index"
    *Cause:    The geometry table does not have a spatial index.
    *Action:   Verify that the geometry table referenced in the spatial operator
    has a spatial index on it.
    Note, the SELECT SHAPE FROM (****) A WHERE SDO_FILTER(....) syntax is a third party application, all we have control is the part inside "(select ...)".
    So it appears Oracle is treating view differently. Have attempted fake the view name into USER_SDO_GEOM_METADATA, did not work. Also, granted select on the index table to user2, did not work.
    if we re-created the view in user2 schema, it worked for user2 but not user1, so it's not something we can do for every user.
    Searched the forum, no good match found. A few posts talked about "union all" in view caused the problem but I do not have the union.
    We are only use Oracle 10g Locator, not full spatial edition.
    Any ideas?
    Thanks!
    Edited by: liu.284 on Oct 4, 2011 12:08 PM

    It seems a bug, where a function-based spatial index is not correctly handled in a view query transformation.
    Not sure if the following works for you or not.
    add a new column "shape" (mdsys.sdo_geometry) in table locations, use a trigger and x_coord/y_coord
    to set values for this new column, and just create a normal spatial index on this new column. (drop the
    function-based spatial index). And create a view like:
    CREATE VIEW USER1.MY_VIEW2 AS SELECT ID , X_COORD, Y_COORD, SHAPE
    FROM USER1.LOCATIONS WHERE X_COORD>0 AND Y_COORD>0;

  • Equivlent CASE WHEN query for Oracle 8.05

    Is there a way to construct a query similar to the statement below in Oracle version 8.05?
    SELECT ename, CASE WHEN empid>10000 THEN 'Old Timer' ELSE 'New Comer' END
    FROM employees;
    I would like to use a single select query to handle such situations. Thanks for any suggestions.
    Roger

    sql>select empid,
      2         decode(sign(10001 - empid), 1, 'Newcomer', 'Oldtimer') description
      3    from foo
      4   order by empid;
        EMPID DESCRIPT
         9999 Newcomer
        10000 Newcomer
        10001 Oldtimer
        10002 Oldtimer

  • Query of Oracle Spatial data in 1.5.4

    I run the below in SQLPLUS and all is well. 1.5.4
    select SDO_gcdr.geocode('ADCI', 2 SDO_keywordArray( '1052 Thomas Jefferson St','Washington,DC 20007'), 'US', 'DEFAULT')
    3 from dual ;
    SDO_GCDR.GEOCODE('ADCI',SDO_KE(ID, ADDRESSLINES, PLACENAME, STREETNAME, INTERSEC
    SDO_GEO_ADDR(0, SDO_KEYWORDARRAY(), NULL, 'THOMAS JEFFERSON ST NW', NULL, NULL,
    'WASHINGTON', NULL, 'DC', 'US', '20007', NULL, '20007', NULL, '1052', 'THOMAS JE
    FFERSON', 'ST', 'F', 'F', NULL, 'NW', 'L', .913793103, 18897889, '????#EN?T?B281
    CP?', 2, 'DEFAULT', -77.060179, 38.9040445)
    I can also get the result in TOAD.
    When I run through SQL Developer I get the below:
    oracle.sql.STRUCT@16433e4

    logged bug 8640482 for this.

  • How to Query Sdo_Geometry Object of ORACLE SPATIAL in PHP?

    Hi,
    I am trying to Query the Oracle Spatial's Geometry object in the PHP page but its giving me the ADT Error. How can i see the GEOMETRY object information on the web using PHP. Thanking you in advance and waiting for ur prompt reply.
    Adnan!

    Hi Ana,
    In the Query below its returning the result as each value of one row in diffrent rows i wanna ask from u is:
    1- May i get all these values in one row ?
    2- Second, i want to query more than one row values from the table? as this is a single row subquery.
    Thanks for your help and i m looking forward for a positive reply from you.
    Regards,
    Adnan!
    The following select lists all ordinate-values from ONE object in the table:
    select *
    from table(select a.<column_name>.sdo_ordinates
    from <table_name> a
    where ID = xxxx
    *******************************************************************

  • Poor performance with Oracle Spatial when spatial query invoked remotely

    Is anyone aware of any problems with Oracle Spatial (10.2.0.4 with patches 6989483 and 7003151 on Red Hat Linux 4) which might explain why a spatial query (SDO_WITHIN_DISTANCE) would perform 20 times worse when it was invoked remotely from another computer (using SQLplus) vs. invoking the very same query from the database server itself (also using SQLplus)?
    Does Oracle Spatial have any known problems with servers which use SAN disk storage? That is the primary difference between a server in which I see this poor performance and another server where the performance is fine.
    Thank you in advance for any thoughts you might share.

    OK, that's clearer.
    Are you sure it is the SQL inside the procedure that is causing the problem? To check, try extracting the SQL from inside the procedure and run it in SQLPLUS with
    set autotrace on
    set timing on
    SELECT ....If the plans and performance are the same then it may be something inside the procedure itself.
    Have you profiled the procedure? Here is an example of how to do it:
    Prompt Firstly, create PL/SQL profiler table
    @$ORACLE_HOME/rdbms/admin/proftab.sql
    Prompt Secondly, use the profiler to gather stats on execution characteristics
    DECLARE
      l_run_num PLS_INTEGER := 1;
      l_max_num PLS_INTEGER := 1;
      v_geom    mdsys.sdo_geometry := mdsys.sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0,0,45,45,90,0,135,45,180,0,180,-45,45,-45,0,0));
    BEGIN
      dbms_output.put_line('Start Profiler Result = ' || DBMS_PROFILER.START_PROFILER(run_comment => 'PARALLEL PROFILE'));  -- The comment name can be anything: here it is related to the Parallel procedure I am testing.
      v_geom := Parallel(v_geom,10,0.05,1);  -- Put your procedure call here
      dbms_output.put_line('Stop Profiler Result = ' || DBMS_PROFILER.STOP_PROFILER );
    END;
    SHOW ERRORS
    Prompt Finally, report activity
    COLUMN runid FORMAT 99999
    COLUMN run_comment FORMAT A40
    SELECT runid || ',' || run_date || ',' || run_comment || ',' || run_total_time
      FROM plsql_profiler_runs
      ORDER BY runid;
    COLUMN runid       FORMAT 99999
    COLUMN unit_number FORMAT 99999
    COLUMN unit_type   FORMAT A20
    COLUMN unit_owner  FORMAT A20
    COLUMN text        FORMAT A100
    compute sum label 'Total_Time' of total_time on runid
    break on runid skip 1
    set linesize 200
    SELECT u.runid || ',' ||
           u.unit_name,
           d.line#,
           d.total_occur,
           d.total_time,
           text
    FROM   plsql_profiler_units u
           JOIN plsql_profiler_data d ON u.runid = d.runid
                                         AND
                                         u.unit_number = d.unit_number
           JOIN all_source als ON ( als.owner = 'CODESYS'
                                   AND als.type = u.unit_type
                                   AND als.name = u.unit_name
                                AND als.line = d.line# )
    WHERE  u.runid = (SELECT max(runid) FROM plsql_profiler_runs)
    ORDER BY d.total_time desc;Run the profiler in both environments and see if you can see where the slowdown exists.
    regards
    Simon

  • PC session hangs when launch a query from Oracle 9i client to 10g database

    I have a pc with Oracle 9.2.0.1.0 client installed. The database server level is 10.1.0.5.
    When I launch a query from a client session the pc sesssion locks up and doesn't return any results. When I launch the same query from the database server , or from other pcs with Oracle client 10 installed , I get results almost immediately from the query.
    The pc in question is running Windows XP Service pack 2. Other queries run fine from the pc.
    Are there are any known issues with Oracle 9 clients querying an Oracle 10 database ?

    Thank you for your reply. No, I must admit I didn't think of looking at the wait events. I will look at this as soon as I get a chance.
    Thanks again for your suggestion.

  • Why oracle spatial query execute so slow???

    hi all,
    I have two oracle spatial table CHI_2007r2 and CHI_2008r2, each table has it's own spatial index,and each table has 2000 row record, Now execute this query,I can get the result soon,
    select /*+ ORDERED */ a.link_id from chi_2007r2 a,chi_2008r2 b where a.link_id=b.link_id and sdo_relate(a.geom,b.geom,'mask=INSIDE querytype=WINDOW')='TRUE';
    But I execute the query by geom only,it will take so long time! query(3 more hours):
    select /*+ ORDERED */ a.link_id,b.link_id from chi_2007r2 a,chi_2008r2 b where sdo_relate(a.geom,b.geom,'mask=INSIDE querytype=WINDOW')='TRUE';
    I don't upderstand...
    thanks
    David

    Because in the first statement
    select /*+ ORDERED */ a.link_id from chi_2007r2 a,chi_2008r2 b where a.link_id=b.link_id and sdo_relate(a.geom,b.geom,'mask=INSIDE querytype=WINDOW')='TRUE'; you are joining the two tables while in the second statement
    select /*+ ORDERED */ a.link_id,b.link_id from chi_2007r2 a,chi_2008r2 b where sdo_relate(a.geom,b.geom,'mask=INSIDE querytype=WINDOW')='TRUE';you are doing a cartesian merge first because there is no join between a and b other than te sdo_relate which will be calculated for every row combination you get.
    But I think you'd be better off posting in the {forum:id=76} forum.
    Best regards,
    PP
    Edited by: porzer on Jan 15, 2009 10:34 AM

  • Very basic question Oracle spatial query

    Hi All,
    Iam a newbie to oracle spatial.
    How can i verify that oracle spatial is installed in my database.
    My database is version is 10.2.0.2.0
    Is there any special query i can execute to test oracle spatial is working properly / installed properly.
    All the finctionality oracle spatial is working properly
    Thanks in advance.
    baskar k

    Spatial     VALID     10.2.0.2.0
    I got this message on executing this query
    +++++++++++++++++++++++++++++++
    SELECT comp_name, status, substr(version,1,10) as version
    from dba_server_registry
    where comp_name = 'Spatial';
    ++++++++++++++++++++++++++++++++

  • Oracle Spatial - LRS component

    Hello,
    I am working as a consultant for a transportation department for building Highway Database Management system .Transportation department uses several Linear Referncing Methods such as Milepoint, Station, Refrence Marker etc to locate an attribute on a route . I am new to Oracle - LRS but have heared that by implementing Oracle-LRS , it can locate route attribute and events by one measure and not with x and y coordinate. Does anyone have implemented Oracle-LRS , if so I would like to know how can I design my dastabase based on LRS.
    What other problems Oracle LRS can solve in my case ?
    I will appreciate if some one can pass me design code etc to look into.
    Thank you.
    Suhail

    Thanks for your advice . I donot have 9i but hope to get very soon, I will give a shot then . One more thing which you mentioned in your previous answer is that one has to write extensive PL/SQL code to use LRS. In my case , I have a simple table of roads and would like to clip a segment of road dynamically and then based on the result I would like to fetch some data from other tables . But I lost here, because I donot have a way to relate data in the other table. I have a simple table say routes to store road geometry and in other route_features table I am storing road features ( attribute of the table is rc_id (pk),route_id_fk,feature_id_fk,feature_value,begin_milepoint,end_milepoint. Both tables are related with one key ie ROUTE_ID .I want to clip a segment of route from first table and then would like to get the data from the second table. I have no idea how I can accomplish this in PL/SQL. Here is my code what I am trying to do
    SQL> SELECT SDO_LRS.CLIP_GEOM_SEGMENT(route_geometry, 15, 30)
    2 FROM routes WHERE route_id = 1;
    SDO_LRS.CLIP_GEOM_SEGMENT(ROUTE_GEOMETRY,5,10)(SDO_GTYPE, SDO_SRID, SDO_POINT(X,
    SDO_GEOMETRY(3302, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(
    5, 4, 5, 8, 4, 8, 10, 4, 10))
    Now in the above result I have the output which is based on x,y,m . How I can use this to get feature_id_fk,feature_value data from teh second table? This is what you mentioned that requires lotof Pl/SQL programming. Could you share soem code here how to accomplis my task.
    I will appreciate your input.
    Thank you.
    Suhail

  • INVALID Oracle Spatial objects

    Hi,
    Me also facing same issue after upgrading the database from 11g R1 to 11g R2. can you please tell how to enable the spacial from invalid to valid .
    Regards,
    Ram

    Pl post details of OS version. Were these objects invalid in the source database ? What options have been enabled in 11gR1 and 11gR2 ?
    How To Validate Oracle Spatial in the DBA_REGISTRY (Doc ID 1100898.1)
    How To Diagnose Components With NON VALID Status In DBA_REGISTRY After an Upgrade (Doc ID 753041.1)
    HTH
    Srini

  • Oracle spawning parallel 128 processes when queried from Cognos

    Hi,
    I am querying a parallel enabled table with DOP set to default. Oracle 11.2 is installed on a 16 core machine while Cognos sits on a 4 core linux system. When querying the same table fromToad, I observe 32 parallel processes. Any thoughts as to why the difference and why that many number of processes get spawned from Cognos?
    Thanks

    What and what are you runnng and how are they configured?
    I ask this because what you are seeing could be as a reulst of so many factors.
    An example is that if you are using Planning Contributor, then you are likely to have more processes reading and writing to the database at the same time. The number of processes will then depend on serveral issues. For instance the number of CPUs on the box, the number of Contributor Applications, the number of Publish Containers and the interval the jobs are configured to run. Using a scenario where you have a single monitorin job on a 2 cpu box for 10 Contributor Applications. Ths may spawn up to 20 processes. To make things worse, if you happen to have some of the previous 20 processes not completing before the next job interval, then it adds more to the number you see.

  • Oracle Spatial on RAC

    Hi,
    We have an application where we use Oracle Spatial (SDO_GEOMETRY) and we use Eclipselink as the JPA provider. When using this on RAC with MutliDatasource with algorithm as "LoadBalancing" we are seeing the following exception when storing entities
    An error has occured flushing the user transaction.
    Caused by: javax.persistence.PersistenceException: Exception EclipseLink-4002 (Eclipse Persistence Services - 2.3.1.v20111018-r10243):
    **org.eclipse.persistence.exceptions.DatabaseException Internal Exception: java.sql.SQLException: Internal Error: Cannot construct STRUCT instance,invalid connection
    Error Code: 17001
    Query: InsertObjectQuery([ TopologyEdgeDAO
    oid=oracle.communications.platform.entity.impl.TopologyEdgeDAO-300013
    !PTDND!=TTFTF entityVersion=1 id=15 name=B01_HYDB.004.LD-B01_HYDB.004
    description=null distance=0.0 edgeType=CONTAINMENT edgeDirection=null
    businessObjectTypeId=9999 fromNodeData=null toNodeData=null
    isPipeInterfaceTerminated=false geometry=null createdDate=Wed Jul 02 16:52:15
    IST 2014 createdUser=<anonymous> partition=null owner=null permissions=null
    The same works in standalone DB or if the MultiDataSource algorithm is failover. Similarly when a RAC node goes down, the same problem exists even with Failover
    I searched in Oracle forums and found the following link which could be related
    https://community.oracle.com/message/1147983#1147983
    By looking at the above pattern, I think if the JGeometry class is passed different connections (one of each node) it fails. Is there a way to clear the descriptors in Eclipselink safely?
    Is Spatial designed to work with RAC ?
    Any pointers on how to solve this is highly appreciated.
    Thanks,
    Rama

    Hello
    You should try to split the upgrade into two tasks - upgrade and migration. Upgrade to 11.2.0.3 on the Windows server first and then migrate to the Linux RAC.
    Spatial will be upgraded as part of the database upgrade, you may need to reindex as per
    http://docs.oracle.com/cd/E11882_01/appdev.112/e11830/sdo_migrat.htm
    There are many ways to migrate from Windows to Linux, you could use RMAN as it is possible to restore Windows backups on Linux and vice versa.
    HTH
    Pavel

Maybe you are looking for