Sdo_elem_info query

Hi,
I like to select all sdo_geomeries from a table (with attribute geometry) where the sdo_elem_info_array equals (1,2,2). I tried statements like:
select * from table t
where t.geometry.sdo_elem_info = (1,2,2);
select * from table t
where t.geometry.sdo_elem_info = sdo_elem_info_array(1,2,2);
and all kind of other variations, but most of the time I receive the error message:
ORA-00932: inconsistent datatypes: expected - got MDSYS.SDO_ELEM_INFO_ARRAY
which is quite vague as it is not mentioning the expected datatype.
Does somebody knows the correct statement?
Friso

Sdo_elem_info_array is a varray. You cannot compare varrays. You have to write your own function to compare the varrays.

Similar Messages

  • Spatial query in a distributed environment

    We want to compare two spatial tables.
    We have (at present identical) tables on two computers GEOSRV0 and NB25.
    On both we have Oracle 10.1.0.2. GEOSRV0 has the WINDOWS 2000 operating system installed, on NB25 there is WINDOWS XP Professional.
    The table is EZG:
    GEOMETRY MDSYS.SDO_GEOMETRY
    GEOMETRY_SK VARCHAR2(15)
    EZG_NR NOT NULL NUMBER
    FLAECHE FLOAT(126)
    The primary key is EZG_NR.
    There is a private database link for the user WLKREP on NB25 to user WLKREP on GEOSRV0.
    The USER_SDO_GEOM_METADATA are the same on both machines (same SRID, same DIMINFO).
    The following query – we check, if for each record on NB25 is a record on GEOSRV0 - works normally:
    SQL> select ezg_nr from
    2 ezg a where not exists
    3 (select 1 from wlkrep.ezg@wlk where ezg_nr=a.ezg_nr);
    no rows selected
    This is correct.
    We can read the geometry on the remote database:
    SQL> select * from wlkrep.ezg@wlk where rownum=1;
    GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
    GEOMETRY_SK EZG_NR FLAECHE
    SDO_GEOMETRY(3003, 1040001, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARRAY(182285.489, 405672.889, 0, 182248.701, 405644.889, 0, 182241.984, 405639.771, 0, 182171.753, 405538.805, 0, 182130.953, 405498.016, 0, 181971.1, 405274.91
    6, 0, 182223.796, 405176.609, 0, 182292.701, 405204.37, 0, 182439.028, 405451.66
    , 0, 182573.506, 405628.153, 0, 182643.64, 405726.59, 0, 182718.945, 405764.608,
    0, 182780.371, 405805.57, 0, 182862.191, 405843.931, 0, 182966.69, 405933.13, 0
    , 183131.065, 406064.852, 0, 183205.098, 406160.637, 0, 183231.535, 406220.959,
    0, 183266.473, 406265.415, 0, 183308.669, 406303.524, 0, 183295.305, 406364.696,
    0, 183204.283, 406331.35, 0, 183161.835, 406299.691, 0, 183134.554, 406243.403,
    GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
    GEOMETRY_SK EZG_NR FLAECHE
    0, 183080.454, 406171.548, 0, 183027.376, 406123.698, 0, 182914.558, 406039.291
    , 0, 182770.335, 405973.138, 0, 182593.691, 405886.413, 0, 182443.506, 405795.85
    2, 0, 182343.293, 405713.991, 0, 182285.489, 405672.889, 0))
    13 304906.065
    Now we want to compare the geometry and get
    SQL> select a.ezg_nr from
    2 wlkrep.ezg@wlk b, ezg a where a.ezg_nr=b.ezg_nr and
    3 sdo_equal(a.geometry,b.geometry) != 'TRUE';
    select a.ezg_nr from
    ERROR at line 1:
    ORA-03113: end-of-file on communication channel
    Only comparing two elements gives the same result
    SQL> select a.ezg_nr from
    2 wlkrep.ezg@wlk b, ezg a where a.ezg_nr=640 and
    3 b.ezg_nr = 640 and
    4 sdo_equal(a.geometry,b.geometry) = 'TRUE';
    select a.ezg_nr from
    ERROR at line 1:
    ORA-03113: end-of-file on communication channel
    Even if we query a non existing element
    select count(*) from ezg where ezg_nr=99999;
    COUNT(*)
    0
    SQL> select a.ezg_nr from
    2 wlkrep.ezg@wlk b, ezg a where a.ezg_nr=99999 and
    3 b.ezg_nr = 99999 and
    4 sdo_equal(a.geometry,b.geometry) = 'TRUE';
    select a.ezg_nr from
    ERROR at line 1:
    ORA-03113: end-of-file on communication channel
    Is this a bug or is a distributed spatial query not supported?
    The following statement works:
    SQL> select a.ezg_nr from
    2 wlkrep.ezg@wlk a where not exists
    3 (select 1 from ezg b where
    4 b.ezg_nr=a.ezg_nr and
    5 sdo_equal(b.geometry,a.geometry)='TRUE');
    no rows selected
    Regards
    Karl

    Actually, I have filed a TAR to Oracle on this. I also spoke to Steve Muench about it at OracleWorld, briefly. As of today, I'm trying to add to DataScroller.java to make it implement java.io.Serializable (with no luck...maybe someone can comment on what I'm doing wrong).
    Here's what I have done so far.
    Changed DataScroller.java (located in bc4jhtmlsrc.zip) to the following:
    public class DataScroller implements java.io.Serializable
    I added the following members per the docs on java.io.Serializable
    private void writeObject(java.io.ObjectOutputStream out)
    throws IOException
    // really don't need to save state. Next call will recompute what's necessary
    private void readObject(java.io.ObjectInputStream in)
    throws IOException, ClassNotFoundException
    // really don't need to load state. Next call will recompute what's necessary
    I then used jar xvf to "unjar" datatags.jar, replaced DataScroller.class with my version and used
    jar cv0Mf datatags.jar META-INF/* oracle/*
    to recreate the datatags.jar. My file is not 100% the exact same as their file, but it looks to be right to me. I ended up doing it this way because the oracle\ord\* classes are not in the bc4jhtmlsrc.zip, only in the jar file and felt this was the "safest" way to include the correct contents of the file.
    HOWEVER -- I'm sorry to say that I've then tried to run my app and get the same issue.
    Thanks,
    Jeff

  • Suggested query (9i) for 3-d Geodetic point-in-poly?

    Hi there,
    Just getting started with Spatial. Have a SDO_POINT_TYPE layer in 8307 (Geodetic Lat/Lon/Height) 3-dim, indexed with 2-dim (Lat/Lon) and want to know what the best way is to perform point-in-polygon queries on this layer (e.g. basic web-mapping interface)? I recently tried SDO_GEOM.RELATE but it was extremely slow, and incorrect....certainly something I'm doing wrong.
    Any help whatsoever is greatly appreciated.
    Thanks in advance,
    Michael

    Thanks very much.
    However, I the query doesn't seem to be giving me what I think it should. My index is two dimensions:
    create index I_MONUMENT_SHAPE on MONUMENT_CATALOG (SHAPE)
    INDEXTYPE IS MDSYS.SPATIAL_INDEX PARAMETERS('layer_gtype=POINT sdo_indx_dims=2');
    "SDO_RELATE" query:
    select mc.char_id as "ID",mc.shape as "Shape" from monument_catalog mc
    where SDO_RELATE(mc.shape,MDSYS.SDO_GEOMETRY(2003,8307,null,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1),
    -- MDSYS.SDO_ORDINATE_ARRAY(-110,20,-110,30,-100,30,-100,20,-110,20)),'mask=inside querytype=WINDOW') = 'TRUE';
    MDSYS.SDO_ORDINATE_ARRAY(-110,20,-110,30,-100,30,-100,20,-110,20)),'mask=anyinteract') = 'TRUE';
    ID Shape(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
    BURR SDO_GEOMETRY(3001, 8307, SDO_POINT_TYPE(-110.066, 23.516, 535.02537), NULL, NULL)
    ANCN SDO_GEOMETRY(3001, 8307, SDO_POINT_TYPE(-110.03, 23.739, 481.56558), NULL, NULL)
    LPAZ SDO_GEOMETRY(3001, 8307, SDO_POINT_TYPE(-110.319, 24.139, -26.9092), NULL, NULL)
    BLND SDO_GEOMETRY(3001, 8307, SDO_POINT_TYPE(-110.309, 24.326, -10.21309), NULL, NULL)
    "vanilla sql" query:
    select mc.char_id as "ID",mc.shape as "Shape" from monument_catalog mc
    where mc.shape.SDO_POINT.X < -100
    and mc.shape.SDO_POINT.X > -110
    and mc.shape.SDO_POINT.Y < 30
    and mc.shape.SDO_POINT.Y > 20;
    ID Shape(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
    CEBO SDO_GEOMETRY(3001, 8307, SDO_POINT_TYPE(-103.161, 20.09, 2009.12022), NULL, NULL)
    JARA SDO_GEOMETRY(3001, 8307, SDO_POINT_TYPE(-101.8, 21.264, 2016.36392), NULL, NULL)
    UMON SDO_GEOMETRY(3001, 8307, SDO_POINT_TYPE(-103.453, 20.737, 1626.65695), NULL, NULL)
    ineg SDO_GEOMETRY(3001, 8307, SDO_POINT_TYPE(-102.284, 21.856, 1888.67922), NULL, NULL)
    AYUT SDO_GEOMETRY(3001, 8307, SDO_POINT_TYPE(-104.374, 20.188, 1648.7741), NULL, NULL)
    CHAC SDO_GEOMETRY(3001, 8307, SDO_POINT_TYPE(-105.429, 20.383, 280.64762), NULL, NULL)
    COSA SDO_GEOMETRY(3001, 8307, SDO_POINT_TYPE(-103.325, 20.293, 1730.68995), NULL, NULL)
    GUAC SDO_GEOMETRY(3001, 8307, SDO_POINT_TYPE(-104.354, 20.501, 1581.31376), NULL, NULL)
    MCAB SDO_GEOMETRY(3001, 8307, SDO_POINT_TYPE(-103.493, 21.092, 1682.41884), NULL, NULL)
    SEBA SDO_GEOMETRY(3001, 8307, SDO_POINT_TYPE(-104.871, 20.699, 1973.90223), NULL, NULL)
    ECER SDO_GEOMETRY(3001, 8307, SDO_POINT_TYPE(-109.81, 24.18, 89.31145), NULL, NULL)
    EMIR SDO_GEOMETRY(3001, 8307, SDO_POINT_TYPE(-109.735, 23.366, 192.75321), NULL, NULL)
    RIVE SDO_GEOMETRY(3001, 8307, SDO_POINT_TYPE(-109.532, 23.549, 40.95293), NULL, NULL)
    LIM2 SDO_GEOMETRY(3001, 8307, SDO_POINT_TYPE(-103.528, 20.335, 1652.13807), NULL, NULL)
    SAUZ SDO_GEOMETRY(3001, 8307, SDO_POINT_TYPE(-103.225, 20.885, 1699.7295), NULL, NULL)
    7122 SDO_GEOMETRY(3001, 8307, SDO_POINT_TYPE(-106.459, 23.343, 27.9281), NULL, NULL)
    3033 SDO_GEOMETRY(3001, 8307, SDO_POINT_TYPE(-109.086, 25.692, -30.58101), NULL, NULL)
    7882 SDO_GEOMETRY(3001, 8307, SDO_POINT_TYPE(-109.864, 22.918, 115.09006), NULL, NULL)
    LIMA SDO_GEOMETRY(3001, 8307, SDO_POINT_TYPE(-103.548, 20.37, 2112.2829), NULL, NULL)
    Any idea why the SDO_RELATE query seems to be giving me stuff just ---outside--- my query window rather that stuff that lies inside?
    Thanks,
    Michael

  • How to access sdo_geometry.sdo_elem_info with occi

    if I use occi,how to access a varray of number(sdo_geometry.sdo_elem_info) in a table such as cola_markets.

    Hi,
    First check whether the given object is supported by streams are not by querying DBA_STREAMS_UNSUPPORTED.
    If it is supported then we can set the negative rule to avoide the problematic column.
    Thanks and Regards,
    Satish.G.S
    http://gssdba.wordpress.com

  • Sdo_elem_info elements

    Hello,
    I would like to select the data in the sdo_elem_info.
    When I use this query:
    select a.geom.sdo_elem_info
    from test a where rownum =1
    I get:
    SDO_ELEM_INFO_ARRAY(1, 1003, 1, 605, 2003, 1)
    I want to select it so it looks like this:
    1|1003|1|605|2003|1
    I have tried several ideas, and searched the archives.
    None of these work:
    select a.geom.sdo_elem_info(0)
    from test a where rownum =1
    select a.geom.sdo_elem_info_array(0)
    from test a where rownum =1
    select a.geom.sdo_elem_info.sdo_elem_info_array(0)
    from test a where rownum =1
    I am using sdo_util.getvertices to get the sdo_ordinates.
    Any help is appreciated.
    Thank you.
    S

    Hello
    For plain SQL the difficulty is dealing with varying length of the array sdo_elem_info. This is how far I got. As you will see this will only return the concatenated first 3 elements.
    In order to have it working in more flexible way you have to make some flexible Pivot table function.
    So it is easier using the function of Dan.
    select id,
    max(decode(rn, 1, column_value)) || '|' ||
       max(decode(rn, 2, column_value))  || '|' ||
           max(decode(rn, 3, column_value)) elem_info
       from
          (select id, column_value,
                  row_number() over (partition by rowid order by rowid) Rn
           from your_table r, table(r.GEOMETRY.SDO_ELEM_INFO)
          ) T
      group by id
    In case you're ok with a normal table record output, you can use Reggie's query or this one listing also the array position of the element for every feature.
    select id, column_value,
                  row_number() over (partition by rowid order by rowid) position
           from your_table r, table(r.GEOMETRY.SDO_ELEM_INFO)Luc

  • Sdo_elem_info

    I'm trying to query sdo_elem_info from a Spatial's geometry column. I can execute this query:
    select a.shape.sdo_gtype from gen.us_states_spat a;
    However, I cannot execute this query:
    select a.shape.sdo_elem_info(1) from gen.us_states_spat a;
    The error message says that I have an invalid column name.
    Also, what is a good way to determine the number of values in the array?
    Thanks!

    DECLARE
    v_shape MDSYS.SDO_GEOMETRY;
    x NUMBER;
    y NUMBER;
    BEGIN
    SELECT a.shape
    INTO v_shape
    FROM my.sdotable a
    WHERE ...
    x := v_shape.SDO_ELEM_INFO.COUNT;
    y := v_shape.SDO_ELEM_INFO(1);
    END;

  • Query for total size of the spatial data

    Hi,
    I found some posts to determine the size of the spatial table but is there a query I can use to determine the exact size of my spatial column. I have about 2 mil. geometry points and I would like to know exactly how many bytes it is.
    Thanks in advance.
    Aarthi

    Hi,
    I have an old analysis I did several years ago. I couldn't get size for the SDO_GEOMETRY column per se, but I could calculate the approximate size required (not including extra space required for block boundaries, etc.). Note this info is quite old, so your milage may vary...
    This is the summary:
    SDO_GTYPE 3 bytes plus 1 byte for every two numeric places  (four digit gtype=5 bytes)
    SDO_SRID 1 byte if NULL; or 3 bytes plus 1 byte for every two numeric places 
    SDO_POINT 1 byte if NULL; or for each of the three numeric values, 1 byte if
                 NULL, or 3 bytes plus 1 byte for every two numeric places 
    SDO_ELEM_INFO 1 byte if NULL; or for each numeric value, 3 bytes plus
                 1 byte for every two numeric places, plus 40 bytes overhead for the VARRAY. 
    SDO_ORDINATES 1 byte if NULL; or for each numeric value, 3 bytes plus
                 1 byte for every two numeric places, plus 40 bytes overhead for the VARRAY. 

  • Query for individual coordinates in SDO_ORDINATES

    Hi,
    How can I query for each coordinate in column SDO_ORDINATES type ?
    I have a geom object with the following data -
    GEOM(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
    SDO_GEOMETRY(2, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(-80, 40, -80, 40))
    How can I query for the individual coordinates in the SDO_ORDINATE_ARRAY?
    Thanks,
    Archana

    I have a geom object with the following data -
    GEOM(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
    SDO_GEOMETRY(2, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(-80, 40, -80, 40))A few comments about this geometry:
    The first value (sdo_gtype) is set to 2. This gtype is a line string.
    If you are storing a 2D line string, you should use 2002
    2000 means 2 dimensional, 2 is a line geometry.
    The data you are storing as the line (-80,40,-80,40) is storing the same point twice. Consecutive points that are
    the same when storing a line segment are not supported in Oracle Spatial. If all you are storing is a point use
    sdo_gtype 2001 (for a point) and store the point in the sdo_point field.
    To just select the information from the ordinate array:
    select a.geom.sdo_ordinates from table a where....
    Hope this helps,
    Dan

  • Query about sdo_relate

    hello,
    I asked this question a while back and I did get a reply.
    Mr. Abugov replied but I only saw his reply today. I'm very sorry for not replying earlier and if anyone would like to offer any advice I would be very grateful.
    Here is the problem:
    I have a shapefile called pppoly.shp. It contains objects of type polygon. I would like to do a query that would find ploygons in pppoly.shp that spatially interact in any way with a given point.
    Here is the query that I was using:
    SELECT geom FROM pppoly WHERE sdo_relate(geom,mdsys.sdo_geometry(2001, 8307, mdsys.sdo_point_type(33.359997,35.17496, NULL) ,NULL, NULL), 'mask=anyinteract querytype=window') = 'TRUE';
    The problem is that from looking at this shapefile in ArcView, I know that the point (33.359997,35.17496) is actually within one of the polygons in pppoly.shp. However when I run this query in SQL-Plus , I get no rows returned.
    Mr. Abugov in his reply had asked for these following pieces of information.
    SQL> select count(*) from pppoly;
    COUNT(*)
    10
    SQL> select geom from pppoly where rownum < 2;
    GEOM(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
    SDO_GEOMETRY(3, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 3, 1), SDO_ORDINATE_ARRAY(34.
    379467, 35.585663, 34.377975, 35.596298, 34.386539, 35.59737, 34.38308, 35.61043
    5, 34.392559, 35.6134, 34.397892, 35.613132, 34.403381, 35.607788, 34.40316, 35.
    600925, 34.406364, 35.591011, 34.404392, 35.588772, 34.379467, 35.585663))
    The geometery that this point interacts with in ArcView is
    has an pppoly_id of 27.
    When I select the geometery with that id I get:
    SQL> select geom from pppoly where pppoly_id =27;
    GEOM(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
    SDO_GEOMETRY(3, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 3, 1), SDO_ORDINATE_ARRAY(33.
    350643, 35.122318, 33.342606, 35.125122, 33.341694, 35.129673, 33.352558, 35.158
    978, 33.332836, 35.164623, 33.331261, 35.170521, 33.331806, 35.177906, 33.338001
    , 35.177307, 33.343845, 35.18129, 33.347778, 35.18103, 33.350384, 35.183468, 33.
    35228, 35.183678, 33.358147, 35.184326, 33.358978, 35.188049, 33.355804, 35.1954
    19, 33.352997, 35.197178, 33.348007, 35.197315, 33.347511, 35.198658, 33.361153,
    35.203335, 33.36697, 35.200417, 33.374664, 35.20219, 33.388039, 35.195522, 33.3
    89416, 35.188946, 33.392128, 35.188713, 33.3965, 35.194576, 33.403988, 35.191742
    , 33.404827, 35.188107, 33.399239, 35.166206, 33.400043, 35.163029, 33.406937, 3
    5.160625, 33.410122, 35.155102, 33.410801, 35.153923, 33.407848, 35.148716, 33.4
    00505, 35.149719, 33.396465, 35.151352, 33.393677, 35.158566, 33.388458, 35.1599
    GEOM(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
    46, 33.386147, 35.153549, 33.391426, 35.144196, 33.39011, 35.139526, 33.386532,
    35.135204, 33.380859, 35.136295, 33.376652, 35.132858, 33.368473, 35.137497, 33.
    36776, 35.152119, 33.362576, 35.152081, 33.360023, 35.131081, 33.355122, 35.1294
    48, 33.350643, 35.122318))
    Thank you for taking the time to read my email.
    Thanks in advance,
    Trish

    Hi Trish,
    This problem is related to the orientation of the geometry. Oracle spatial requires the external rings of polygons to be stored with counterclockwise rotation, and the internal rings of polygons to be stored in clockwise rotation. There is a lot to talk about with regards to this which I won't go into here.
    Oracle provides a migration routine (sdo_migrate.to_current) that ensures all of the requirements with respect to polygon storage are correct.
    This is what I did with your data.
    loaded it
    added metadata to user_sdo_geom_metadata
    built the index
    tried your query - it returned the same answer that you got.
    dropped the index.
    migrated the data.
    recreated the index.
    tried your query - got the correct answer.
    Here it is in detail:
    create table pppoly (id number, geom mdsys.sdo_geometry);
    insert into user_sdo_geom_metadata values ('PPPOLY','GEOM',
    MDSYS.SDO_DIM_ARRAY(
    MDSYS.SDO_DIM_ELEMENT('X', -180, 180, 0.05),
    MDSYS.SDO_DIM_ELEMENT('Y', -90, 90, 0.05)),8307);
    insert into pppoly values (26,
    MDSYS.SDO_GEOMETRY(3, 8307, NULL, mdsys.SDO_ELEM_INFO_ARRAY(1, 3, 1),
    mdsys.SDO_ORDINATE_ARRAY(34.379467, 35.585663, 34.377975, 35.596298,
    34.386539, 35.59737, 34.38308, 35.610435, 34.392559, 35.6134,
    34.397892, 35.613132, 34.403381, 35.607788, 34.40316, 35.600925,
    34.406364, 35.591011, 34.404392, 35.588772, 34.379467, 35.585663)));
    insert into pppoly values (27,
    MDSYS.SDO_GEOMETRY(3, 8307, NULL, mdsys.SDO_ELEM_INFO_ARRAY(1, 3, 1),
    mdsys.SDO_ORDINATE_ARRAY(33.350643, 35.122318, 33.342606, 35.125122,
    33.341694, 35.129673, 33.352558, 35.158978, 33.332836, 35.164623,
    33.331261, 35.170521, 33.331806, 35.177906, 33.338001, 35.177307,
    33.343845, 35.18129, 33.347778, 35.18103, 33.350384, 35.183468,
    33.35228, 35.183678, 33.358147, 35.184326, 33.358978, 35.188049,
    33.355804, 35.195419, 33.352997, 35.197178, 33.348007, 35.197315,
    33.347511, 35.198658, 33.361153,35.203335, 33.36697, 35.200417,
    33.374664, 35.20219, 33.388039, 35.195522, 33.389416, 35.188946,
    33.392128, 35.188713, 33.3965, 35.194576, 33.403988, 35.191742,
    33.404827, 35.188107, 33.399239, 35.166206, 33.400043, 35.163029,
    33.406937, 35.160625, 33.410122, 35.155102, 33.410801, 35.153923,
    33.407848, 35.148716, 33.400505, 35.149719, 33.396465, 35.151352,
    33.393677, 35.158566, 33.388458, 35.159946, 33.386147, 35.153549,
    33.391426, 35.144196, 33.39011, 35.139526, 33.386532,35.135204,
    33.380859, 35.136295, 33.376652, 35.132858, 33.368473, 35.137497,
    33.36776, 35.152119, 33.362576, 35.152081, 33.360023, 35.131081,
    33.355122, 35.129448, 33.350643, 35.122318)));
    commit;
    create index pppoly_sidx on pppoly(geom)
    indextype is mdsys.spatial_index;
    SELECT geom
    FROM pppoly
    WHERE sdo_relate(geom,
    mdsys.sdo_geometry(2001, 8307,
    mdsys.sdo_point_type(33.359997,35.17496, NULL) ,NULL, NULL),
    'mask=anyinteract querytype=window') = 'TRUE';
    drop index pppoly_sidx;
    execute sdo_migrate.to_current('PPPOLY','GEOM');
    create index pppoly_sidx on pppoly(geom)
    indextype is mdsys.spatial_index;
    SELECT geom
    FROM pppoly
    WHERE sdo_relate(geom,
    mdsys.sdo_geometry(2001, 8307,
    mdsys.sdo_point_type(33.359997,35.17496, NULL) ,NULL, NULL),
    'mask=anyinteract querytype=window') = 'TRUE';
    Hope this helps,
    Dan (Mr Abugov is my father)

  • Error while running a query-Input for variable 'Posting Period is invalid

    Hi All,
    NOTE: This error is only cropping up when I input 12 in the posting period variable selection. If I put in any other value from 1-11 I am not getting any errors. Any ideas why this might be happening?
    I am getting the following error when I try and run a query - "Input for variable 'Posting Period (Single entry, mandatory)' is invalid" - On further clicking on this error the message displayed is as follows -
    Diagnosis
    Variable Posting Period (Single Value Entry, Mandatory) is used as a lower limit (X) and an upper limit () in an interval selection. This limit has the value #.
    System Response
    Procedure
    Enter a different value for variable Posting Period (Single Value Entry, Mandatory). If the value of the other limit is determined by another variable, you can change its value also.
    Procedure for System Administration

    OK.
    Well, if the variable is not used in any interval selection, then I would say "something happened to it".
    I would make a copy of the query and run it to check if I get the same problem with period 12.
       -> If not, something is wrong in the original query (you can proceed as below, if changes to original are permitted).
    If so, then try removing the variable completely from the query and hardcode restriction to 12.
       -> If problem still persists, I would have to do some thinking.
    If problem is gone, then add the variable again. Check.
       -> If problem is back, then the variable "is sick". Only quick thing to do, is to build an identical variable and use that one.
    If problem also happens with the new variable, then it's time to share this experience with someone else and consider raising an OSS.
    Good luck!
    Jacob
    P.S: what fisc year variant are you using?
    Edited by: Jacob Jansen on Jan 25, 2010 8:36 PM

  • Logical database in adhoc query

    Hello All,
    Can anyone tell me what is the logical database in adhoc query?

    Hi
    When you create a query , you have to select an infoset. Infoset can be considered as a source from which data is populated in the Query Fields.
    Infosets are created from Transaction SQ02.
    There can be four methods through which an Infoset can become a source of data:
    1.  Table join ( By joining two or more tables from Data dictionary)
         example: Joining tables PA0001 and PA0006 on Pernr to get a one resultant dataset
    2. Direct read of Basis Table ( Like PA0001 as a source for data in Infoset )
    3. Logical Database ( A Pre-written Program by SAP that extract data from clusters, tables taking care of authorizations and validity periods)
    Example : Logical database PNP, PNPCE (Concurrent Employement),PCH ( LDB for Personnel Development Data)
    Custom Logical DBs can be created in T_Code SE-36.
    4. Data Retrieval by a Program ( Custom code written by ABAP developers which will collect and process data) . This program has a corresponding Structure in data dictionary and the fields of this structure will be used in query)
    Reward Points, if helpful.
    Regards
    Waseem Imran

  • Query help on Goods Receipt Query with AP Invoice

    Looking for a little help on a query.  I would like to list all the goods receipts for a given date range and then display the AP Invoice information (if its been copied to an AP Invoice).  I think my problem is in my where clause, I plagerized an SAP query to show GR and AP from a PO as a start.  SBO 2005 SP01.  Any help would be great appreciated.  Thanks
    SELECT distinct 'GR',
    D0.DocStatus,
    D0.DocNum ,
    D0.DocDate,
    D0.DocDueDate,
    D0.DocTotal,
    'AP',
    I0.DocStatus,
    I0.DocNum ,
    I0.DocDate,
    I0.DocDueDate,
    I0.DocTotal,
    I0.PaidToDate
    FROM
    ((OPDN  D0 inner Join PDN1 D1 on D0.DocEntry = D1.DocEntry)
    full outer join
    (OPCH I0 inner join PCH1 I1 on I0.DocEntry = I1.DocEntry)
    on (I1.BaseType=20 AND D1.DocEntry = I1.BaseEntry AND D1.LineNum=I1.BaseLine))
    WHERE
    (D1.BaseType=22 AND D1.DocDate>='[%0]' AND D1.DocDate<='[%1]')
    OR (I1.BaseType=20 AND I1.BaseEntry IN
    (SELECT Distinct DocEntry
    FROM PDN1 WHERE BaseType=22 AND DocDate>='[%0]' AND DocDate<='[%1]'))

    Hi Dalen ,
    I  believe it is because of the condition
    (D1.BaseType=22 AND D1.DocDate>='%0' AND D1.DocDate<='%1')
    OR (I1.BaseType=20 AND I1.BaseEntry IN
    (SELECT Distinct DocEntry FROM PDN1 WHERE PDN1.BaseType=22 AND DocDate>='%0' AND DocDate<='%1'))
    Try changing
    D1.BaseType=22 OR D1.DocDate>='%0' AND D1.DocDate<='%1
    PDN1.BaseType=22 OR DocDate>='%0' AND DocDate<='%1'))
    Lets see what would be the result . Lets have some fun with troubleshooting
    See what would be the difference in the result .
    Thank you
    Bishal

  • Can you check for data in one table or another but not both in one query?

    I have a situation where I need to link two tables together but the data may be in another (archive) table or different records are in both but I want the latest record from either table:
    ACCOUNT
    AccountID     Name   
    123               John Doe
    124               Jane Donaldson           
    125               Harold Douglas    
    MARKETER_ACCOUNT
    Key     AccountID     Marketer    StartDate     EndDate
    1001     123               10526          8/3/2008     9/27/2009
    1017     123               10987          9/28/2009     12/31/4712    (high date ~ which means currently with this marketer)
    1023     124               10541          12/03/2010     12/31/4712
    ARCHIVE
    Key     AccountID     Marketer    StartDate     EndDate
    1015     124               10526          8/3/2008     12/02/2010
    1033     125               10987         01/01/2011     01/31/2012  
    So my query needs to return the following:
    123     John Doe                        10526     8/3/2008     9/27/2009
    124     Jane Donaldson             10541     12/03/2010     12/31/4712     (this is the later of the two records for this account between archive and marketer_account tables)
    125     Harold Douglas               10987          01/01/2011     01/31/2012     (he is only in archive, so get this record)
    I'm unsure how to proceed in one query.  Note that I am reading in possibly multiple accounts at a time and returning a collection back to .net
    open CURSOR_ACCT
              select AccountID
              from
                     ACCOUNT A,
                     MARKETER_ACCOUNT M,
                     ARCHIVE R
               where A.AccountID = nvl((select max(M.EndDate) from Marketer_account M2
                                                    where M2.AccountID = A.AccountID),
                                                      (select max(R.EndDate) from Archive R2
                                                    where R2.AccountID = A.AccountID)
                   and upper(A.Name) like parameter || '%'
    <can you do a NVL like this?   probably not...   I want to be able to get the MAX record for that account off the MarketerACcount table OR the max record for that account off the Archive table, but not both>
    (parameter could be "DO", so I return all names starting with DO...)

    if I understand your description I would assume that for John Dow we would expect the second row from marketer_account  ("high date ~ which means currently with this marketer"). Here is a solution with analytic functions:
    drop table account;
    drop table marketer_account;
    drop table marketer_account_archive;
    create table account (
        id number
      , name varchar2(20)
    insert into account values (123, 'John Doe');
    insert into account values (124, 'Jane Donaldson');
    insert into account values (125, 'Harold Douglas');
    create table marketer_account (
        key number
      , AccountId number
      , MktKey number
      , FromDt date
      , ToDate date
    insert into marketer_account values (1001, 123, 10526, to_date('03.08.2008', 'dd.mm.yyyy'), to_date('27.09.2009', 'dd.mm.yyyy'));
    insert into marketer_account values (1017, 123, 10987, to_date('28.09.2009', 'dd.mm.yyyy'), to_date('31.12.4712', 'dd.mm.yyyy'));
    insert into marketer_account values (1023, 124, 10541, to_date('03.12.2010', 'dd.mm.yyyy'), to_date('31.12.4712', 'dd.mm.yyyy'));
    create table marketer_account_archive (
        key number
      , AccountId number
      , MktKey number
      , FromDt date
      , ToDate date
    insert into marketer_account_archive values (1015, 124, 10526, to_date('03.08.2008', 'dd.mm.yyyy'), to_date('02.12.2010', 'dd.mm.yyyy'));
    insert into marketer_account_archive values (1033, 125, 10987, to_date('01.01.2011', 'dd.mm.yyyy'), to_date('31.01.2012', 'dd.mm.yyyy'));
    select key, AccountId, MktKey, FromDt, ToDate
         , max(FromDt) over(partition by AccountId) max_FromDt
      from marketer_account
    union all
    select key, AccountId, MktKey, FromDt, ToDate
         , max(FromDt) over(partition by AccountId) max_FromDt
      from marketer_account_archive;
    with
    basedata as (
    select key, AccountId, MktKey, FromDt, ToDate
      from marketer_account
    union all
    select key, AccountId, MktKey, FromDt, ToDate
      from marketer_account_archive
    basedata_with_max_intervals as (
    select key, AccountId, MktKey, FromDt, ToDate
         , row_number() over(partition by AccountId order by FromDt desc) FromDt_Rank
      from basedata
    filtered_basedata as (
    select key, AccountId, MktKey, FromDt, ToDate from basedata_with_max_intervals where FromDt_Rank = 1
    select a.id
         , a.name
         , b.MktKey
         , b.FromDt
         , b.ToDate
      from account a
      join filtered_basedata b
        on (a.id = b.AccountId)
    ID NAME                     MKTKEY FROMDT     TODATE
    123 John Doe                  10987 28.09.2009 31.12.4712
    124 Jane Donaldson            10541 03.12.2010 31.12.4712
    125 Harold Douglas            10987 01.01.2011 31.01.2012
    If your tables are big it could be necessary to do the filtering (according to your condition) in an early step (the first CTE).
    Regards
    Martin

  • Query help : Query to get values SYSDATE-1 18:00 hrs to SYSDATE 08:00 hrs

    Hi Team
    I want the SQl query to get the data for the following comparison : -
    Order Created is a Date Column , and i want to find out all the values from (SYSDATE-1) 18:00 hours to SYSDATE 08:00 hours
    i.e.
    (SYSDATE-1) 18:00:00 < Order.Created < SYSDATE 08:00:00.
    Regards

    Hi, Rohit,
    942281 wrote:
    If i want the data in the below way i.e.
    from (SYSDATE-1) 18:00 hours to SYSDATE 17:59 hours ---> (SYSDATE-1) 18:00:00 < Order.Created < SYSDATE 07:59:00.If you want to include rows from exactly 18:00:00 yesterday (but no earlier), and exclude rows from exatly 08:00:00 today (or later), then use:
    WHERE   ord_dtl.submit_dt  >= TRUNC (SYSDATE) - (6 / 24)
    AND     ord_dtl.submit_dt  <  TRUNC (SYSDATE) + (8 / 24)
    So can i use the below format : -
    ord_dtl.submit_dt BETWEEN trunc(sysdate)-(6/24) and trunc(sysdate)+(7.59/24) . Please suggest . .59 hours is .59 * 60 * 60 = 2124 seconds (or .59 * 60 = 35.4 minutes), so the last time included in the range above is 07:35:24, not 07:59:59.
    If you really, really want to use BETWEEN (which includes both end points), then you could do it with date arithmentic:
    WHERE   ord_dtl.submit_dt  BETWEEN  TRUNC (SYSDATE) - (6 / 24)
                      AND         TRUNC (SYSDATE) + (8 / 24)
                                               - (1 / (24 * 60 * 60))but it would be simpler and less error prone to use INTERVALs, as Karthick suggested earlier:
    WHERE   ord_dtl.submit_dt  BETWEEN  TRUNC (SYSDATE) - INTERVAL '6' HOUR
                      AND         TRUNC (SYSDATE) + INTERVAL '8' HOUR
                                               - INTERVAL '1' SECONDEdited by: Frank Kulash on Apr 17, 2013 9:36 AM
    Edited by: Frank Kulash on Apr 17, 2013 11:56 AM
    Changed "- (8 /24)" to "+ (8 /24)" in first code fragment (after Blushadown, below)

  • Query help, subtract two query parts

    Hi,
    I am beginner of PL/SQL and have a problem I couldn’t solve:
    Table (op_list):
    Item     -     Amount -     Status
    Item1     -     10     -     in
    Item2     -     12     -     in
    Item3     -     7     -     in
    Item1     -     2     -     out
    Item2     -     3     -     out
    Item1     -     1     -     dmg
    Item3     -     3     -     out
    Item1     -     2     -     out
    Item2     -     5     -     out
    Item2     -     2     -     in
    Item3     -     1     -     exp
    Would like to get result of query (subtract amount of 'out/dmg/exp' from 'in' ):
    Item - Amount left
    Item1     -     5
    Item2     -     6
    Item3 -     3
    I wrote code that returns sum of all incoming items and sum all out/dmg/exp items, but couldn’t solve how to subtract one part of querry from another. Or maybe there is a better way. Also worried what happens if there is no 'out/dmg/exp' only 'in'
    select item.name, sum(op_list.item_amount)
    from op_list
    inner join item
    on op_list.item = item.item_id
    where op_list.status = 'in'
    group by item.name
    union
    select item.name, sum(op_list.item_amount)
    from op_list
    inner join item
    on op_list.item = item.item_id
    where op_list.status = 'out'
    or op_list.status = 'dmg'
    or op_list.status = 'exp'
    group by item.name
    Return:
    Item1     -     10      [10 in]
    Item1     -     5     [2+1+2]
    Item2     -     14     [12+2]
    Item3     -     7
    Item3     -     4     [3+1]
    Thanks in advance

    Hi,
    We can also use simple inline views to get what we need.
    select a.item,a.amount-b.amount Balance from
    (select item,sum(amount) Amount from op_list
    where status = 'in'
    group by item) a,
    (select item,sum(amount) Amount from op_list
    where status in ('out','dmg','exp')
    group by item) b
    where
    a.item=b.item
    order by item;
    ITEM       BALANCE
    Item1                      5
    Item2                      6
    Item3                      3Regards,
    Prazy

Maybe you are looking for