How to execute Oracle Spatial Query

I'd like to return a set of SDO_GEOMETRY columns of MDSYS.SDO_GEOM.SDO_BUFFER(geom, dim, distance) Spatial Function by MDSYS.SDO_WITHIN_DISTANCE(T.column,aGeom,params) Spatial Operator.
Does anyone have experience doing this? Is there a better way to return an SDO_GEOMETRY column of MDSYS.SDO_GEOM.SDO_BUFFER(geom, dim, distance) Spatial Function.
Assume I have a table "my_table" defined as
STANUMBER VARCHAR2(5)
STANAME VARCHAR2(18)
TYPE NUMBER(2)
LAYER NUMBER
STAPROVINCE VARCHAR2(6)
STACOUNTY VARCHAR2(23)
STALATITUDE NUMBER
STALONGITUDE NUMBER
STANUMBER_2 VARCHAR2(5)
STANAME_2 VARCHAR2(18)
TYPE_2 NUMBER(2)
LAYER_2 NUMBER
STAPROVINCE_2 VARCHAR2(6)
STACOUNTY_2 VARCHAR2(23)
GEOLOC MDSYS.SDO_GEOMETRY
--use the MDSYS.SDO_GEOM.SDO_BUFFER(geom, dim, distance) Spatial Function.
select MDSYS.SDO_GEOM.SDO_BUFFER(geoloc,
(select diminfo from user_sdo_geom_metadata m where
m.table_name='STA_QZT1' and m.column_name='GEOLOC'),10)
FROM STA_QZT1 a WHERE a.STANUMBER=12345;
--The right result as follwing:
MDSYS.SDO_GEOM.SDO_BUFFER(GEOLOC,(SELECTDIMINFOFROMUSER_SDO_GEOM_METADATAMWHEREM
SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1005, 6, 1, 2, 2, 5, 2, 1,
7, 2, 2, 11, 2, 1, 13, 2, 2, 17, 2, 1), SDO_ORDINATE_ARRAY(83.171677, 57.508809
4, 72.4970097, 48.2324159, 81.7734032, 37.5577486, 82.6298628, 37.4977234, 94.05
59481, 34.5268537, 100.350233, 44.5150204, 100.130743, 47.6855154, 97.2287, 54.0
629335, 90.853757, 56.9704094, 83.171677, 57.5088094))
--use the MDSYS.SDO_WITHIN_DISTANCE(T.column,aGeom,params) Spatial Operator.
select s.stanumber from sta_qzt1 s where
MDSYS.SDO_WITHIN_DISTANCE(s.geoloc,MDSYS.SDO_GEOMETRY(2003, 8192, NULL,
MDSYS.SDO_ELEM_INFO_ARRAY(1, 1003, 1), MDSYS.SDO_ORDINATE_ARRAY(125.923454,
57.457314, 121.5189, 51.845055, 126.989075, 48.506115, 133.38278, 55.04191,
125.923454, 57.457314)),'distance = 0' )= 'TRUE';
--The right result as follwing:
STANU
11110
However, joint to use the above function to execute a buffer query(cannot work) at PL/SQL:
select s.stanumber from sta_qzt1 s where
(select mdsys.sdo_geom.sdo_buffer(geoloc,
(select diminfo from user_sdo_geom_metadata m where m.table_name='STA_QZT1'
and m.column_name='GEOLOC'),10)
FROM STA_QZT1 a WHERE a.STANUMBER=12345),
'distance = 0' )= 'TRUE';
PL/SQL give out the error information as following:
ERROR at line 5:
ORA-00936: lack of expression
null

Jack,
This should work:
select MDSYS.SDO_GEOM.SDO_BUFFER(geoloc,
(select diminfo from user_sdo_geom_metadata m where
m.table_name='STA_QZT1' and m.column_name='GEOLOC'),10)
from sta_qzt1 s where MDSYS.SDO_WITHIN_DISTANCE(s.geoloc,
MDSYS.SDO_GEOMETRY(2003, 8192, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1, 1003, 1), MDSYS.SDO_ORDINATE_ARRAY(125.923454,
57.457314, 121.5189, 51.845055, 126.989075, 48.506115, 133.38278, 55.04191, 125.923454, 57.457314)),
'distance = 0' )= 'TRUE';

Similar Messages

  • How to install Oracle spatial in existing 10g database

    Hi all,
    I am using Oracle 10g 10.2.0.1.0 on Windows.
    How to install Oracle spatial in my database.
    I tried to do with DBCA with configure database option but in that Oracle spatial is in disabled state.
    Please help I am newby to Oracle spatial
    -Thanks & cheers
    Antony

    Hi Xaheer,
    Thank you very much. I run that script, while running the script in some part its showing some errors.
    Could you please tell me whether I have to do some task before executing this script.
    -Thanks & Cheers
    Antony

  • How to execute oracle stored procedure through php as externally?

    hi...
    i am searching for the way that how to execute oracle stored procedure through web service, i am using php and mysql, i have some stored procedures in oracale database, i want to execute them, from php, means the database will be remain mysql, and the stored procedures of oracle will be executed externally...
    Kind regards,
    Wilayat.

    Ok, so first of all this is a kind of strange question. Since Oracle and MYSQL can happily live side by side.
    Make sure you have the oracle client (instant or regular ) installed and OCI_8 is set up and working correctly in PHP. If it is, when you run the phpinfo() routine you will see oci_8 on there. IF PHP connects just fine from the command line yet apache wont connect check permissions and things like the LD_Library Path.
    Then in php, right along with your MySQL statements run Oracle Statements eg:
    <?php
    $OraDB = oci_connect(name,pass,tnsname);
    $MySQLdb = mysql_connect([parms]);
    $oraQueryText = "begin sp_some_proc([some parms]); end;" ;
    $mysqlQuery = " Some mysql Query";
    $oraQuery = oci_parse($OraDB,$oraQueryText );
    oci_execute($oraQuery);
    mysql_execute([parms]);
    ?>
    Use the standard fetch code to get data from either of them.
    If you cannot and I mean absolutely cannot get an admin to link in OCI_8 then you still have recourse although it will be tedious as hell. PHP allows you to exec calls to the OS. You still MUST make sure the Oracle Client is installed and that sqlplus runs from the command line. You will more then likely have to have a shell script written to do this as well, but maybe not as I have never tried it with the exception of capturing the return value of sqlplus and you will have to dig into sqlplus to get it to send its results to a file you can then parse with php.
    Good Luck!

  • How to execute an SQL query present in a string inside an ABAP program?

    hello,
    How to execute an SQL query present in a string inside an ABAP program

    Raut,
    You can execute Native SQl statements.
    Ex: To use a Native SQL statement, you must precede it with the EXEC SQL statement, and follow it with the ENDEXEC statement as follows:
    EXEC SQL [PERFORMING <form>].
      <Native SQL statement>
    ENDEXEC.
    There is no period after Native SQL statements. Furthermore, using inverted commas (") or an asterisk (*) at the beginning of a line in a native SQL statement does not introduce a comment as it would in normal ABAP syntax. You need to know whether table and field names are case-sensitive in your chosen database.
    In Native SQL statements, the data is transported between the database table and the ABAP program using host variables. These are declared in the ABAP program, and preceded in the Native SQL statement by a colon (:). You can use elementary structures as host variables. Exceptionally, structures in an INTO clause are treated as though all of their fields were listed individually.
    If the selection in a Native SQL SELECT statement is a table, you can pass it to ABAP line by line using the PERFORMING addition. The program calls a subroutine <form> for each line read. You can process the data further within the subroutine.
    As in Open SQL, after the ENDEXEC statement, SY-DBCNT contains the number of lines processed. In nearly all cases, SY-SUBRC contains the value 0 after the ENDEXEC statement. Cursor operations form an exception: After FETCH, SY-SUBRC is 4 if no more records could be read. This also applies when you read a result set using EXEC SQL PERFORMING.
    EXEC SQL PERFORMING loop_output.
      SELECT connid, cityfrom, cityto
      INTO   :wa
      FROM   spfli
      WHERE  carrid = :c1
    ENDEXEC.
    Pls. Mark If useful

  • How to execute this SQL Query in ABAP Program.

    Hi,
    I have a string which is the SQL Query.
    How to execute this sql Query (SQL_STR) in ABAP Program.
    Code:-
    DATA: SQL_STR type string.
    SQL_STR = 'select * from spfli.'.
    Thanks in Advance,
    Vinay

    Hi Vinay
    Here is a sample to dynamically generate a subroutine-pool having your SQL and calling it.
    REPORT dynamic_sql_example .
    DATA: BEGIN OF gt_itab OCCURS 1 ,
    line(80) TYPE c ,
    END OF gt_itab .
    DATA gt_restab TYPE .... .
    DATA gv_name(30) TYPE c .
    DATA gv_err(120) TYPE c .
    START-OF-SELECTION .
    gt_itab-line = 'REPORT generated_sql .' .
    APPEND gt_itab .
    gt_itab-line = 'FORM exec_sql CHANGING et_table . ' .
    APPEND gt_itab .
    gt_itab-line = SQL_STR .
    APPEND gt_itab .
    gt_itab-line = 'ENDFORM.' .
    APPEND gt_itab .
    GENERATE SUBROUTINE POOL gt_itab NAME gv_name MESSAGE gv_err .
    PERFORM exec_sql IN PROGRAM (gv_name) CHANGING gt_restab
    IF FOUND .
    WRITE:/ gv_err .
    LOOP AT gt_result .
    WRITE:/ .... .
    ENDLOOP .
    *--Serdar

  • 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';
    ++++++++++++++++++++++++++++++++

  • How to execute a sql query in VO????

    Hi every body.
    Can you show me the way to execute a sql query in VO.
    For example: I have a viewobject1, and I add a new method void execSQL() before the last '}' of the java file of viewobject1 like this:
    public void execSQL() {
    String strSql = "Select sysdate from dual";
    I want to execute strSql query and return a Resultset, how can I perform ???
    Thanks a lot.

    The executeQuery method in ViewObjectImpl does not return a ResultSet.
    ViewObjectImpl voImpl;
    voImpl.setQuery(strSql);
    voImpl.executeQuery();

  • How to execute a BI query/view from a web dynpro application?

    Hi all,
    I am trying to connect to a BI system from a Web Dynpro application. I have to execute a view/query and process the output in my application. Please guide me about how to establish the connection to the BI system from my web dynpro application and then execute the query/view.
    I have tried executing/modelling the BI query/view using Visual Composer but I get an error saying 'QueryView Instantiation failed' when I try to drag the view/query on to the design board.
    Please guide me and help me achieve this.
    Thanks & Regards,
    Kishan

    Hi Kishan,
    Define system for BI in portal and define JCo destination, then from WDJ application use can query BI.
    Create the Technical System and connect with JCO Destinations
    or
    Connecting through the BI Connecters (ex: XMLA Connecter)
    Refer below link:-
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/60f35908-ecd4-2910-6c89-e75e1054d9d1?quicklink=index&overridelayout=true
    http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/60f35908-ecd4-2910-6c89-e75e1054d9d1
    In this document you will get details related to connector and other admin activity.
    Hope this may help you.
    Deepak!!!

  • How to use Oracle Spatial in this scenario

    My scenario is like that:
    I'm very new to Oracle Spatial
    I'm building an application that will be based on asp.net.(I am
    confident about .net)
    As per my client requirement there are some kml file in one archive
    folder.
    Let me give an example:
    say there is a kml file for region A.(latitude say 36 n to 40 n and
    longitude is 110 w to 115 w) already in the archive folder.
    Now if a new kml file(say A1.kml) that has been created by the user
    and say its latitude and longitude are respectively 37n and 112w. As we clicked A.kml, google earth is opened up for the region A and as
    we move our mouse cursor to more deeper more polygons are visible.
    eventually polygon for A1.kml is also visible and definitely which is
    inside the polygon for region A.
    How can I achieve this thing by using oracle spatial 10g? ---(it's one of my senior's advice to use "oracle spatial 10g" in this scenario)
    I'm not too sure whether I can able to make it clear to u about my
    situation; plz xcuse me if I'm wasting ur valuable time.

    Hi,
    This link helped me a lot!
    http://www.oracle.com/technology/pub/articles/rubio-mashup.html
    Hope it could help you too.
    Best regards,
    Luiz

  • Oracle spatial query with php

    Hello, I have this problem,
    I use php for read data from oracle table,
    all works right, I have any problem whith varchar number type data, but when I must read geometry data like
    (type MDSYS.SDO_GEOMETRY)
    I can't display it on the web page.
    esemple of spatial query that I use:
    select GEOMETRY_1
    from table_a
    where
    ID = 970;
    If I use sql plus I have this result
    SDO_GEOMETRY(3001, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 0, 6000, 4, 1, 1), SDO_ORDINATE_ARRAY(1, -0, -
    0, 580094, 4998494, -1))
    but blank page when I use php sentence.
    I use PHP Version 4.4.0
    modules load are:
    extension=php_sdo.dll
    extension=php_oci8.dll
    But I don't know which other module I need and also which php function to use for read array of array. at the moment I use @OCIFetchInto.
    Someone can help me?
    My English is very bad please reply easy.
    Thanks for all!
    Angelo

    Thank you very much CJ.
    Now there isn't any problems: you and this link (Re: PHP and spatial data and Adamo Bozzetti helped me
    I have used SDO_UTIL.GETVERTICES
    my complete php script is:
    $conn = @OCILogon("xxxxxx", "xxxxx", "xxxxx") or die
    ( "Non riesco a connettermi al server $host ");
    $query = "select
    TABLE_A.tipo_via,
    TABLE_A.nome_via,
    c.codice_via,
    t.X,
    t.Y
    from TABLE B c, TABLE_A , TABLE(SDO_UTIL.GETVERTICES(c.geometry1)) t
    where c.codice_via = 830
    and c.codice_via = TABLE_A.id_via
    $istruzione = @OCIParse($conn, $query);
    @OCIExecute($istruzione);
    $nrows = @OCIFetchInto($istruzione, $results);
    $trovati = 0;
    while(@OCIFetchInto($istruzione, $results))
    $trovati++;
    ?>     
    <table border width="800" >
    <tr>     
    <td align="center" width="80" bgcolor ="#aaffee"><?echo trim($results[0]);?></td>
    <td align="center" width="150" bgcolor ="#eeffee"><?echo trim($results[1]);?></td>
    <td align="center" width="50" bgcolor ="#eeffee"><?echo trim($results[2]);?></td>
    <td align="center" width="50" bgcolor ="#eeffee"><?echo trim($results[3]);?></td>
    <td align="center" width="50" bgcolor ="#eeffee"><?echo trim($results[4]);?></td>
    </tr>
    </table>
    <?
    } //fine While
    @OCIFreeStatement($istruzione);
    @OCILogOff($conn);

  • Oracle spatial query SDO_LRS with php

    Hello, I have this problem,
    I use php for read data from oracle table.
    I know I can't show on web page the result of SDO_ORDINATE_ARRAY
    Christopher Jones has written that I must use SDO_UTIL.GETVERTICES like as
    select
    t.X,
    t.Y
    from table_a, TABLE(SDO_UTIL.GETVERTICES(table_a.GEOMETRY_1)) t
    where
    id_num = 970;
    But now I must read a projection point ordinate of a point with respect to a geometric segment
    and the same problem come back.
    esemple of spatial query that I use:
    SELECT
    SDO_LRS.PROJECT_PT(geometry,
    SDO_GEOMETRY(3301, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1, 1), SDO_ORDINATE_ARRAY(580094.69, 4998493.68, NULL)) )
    FROM
    TABLE_B
    WHERE
    ID_CODE = 970;
    If I use sql plus I have this result
    SDO_LRS.PROJECT_PT(GEOMETRY,SD(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM
    SDO_GEOMETRY(3301, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1, 1), SDO_ORDINATE_ARRAY(
    580093,325, 4998497,57, 45,2254405))
    Which is exacly the query for extract these coordinates?
    Someone can help me?
    My English is very bad please reply easy.
    Thanks for all!
    Angelo

    Hello thanks for all to everyboby.
    I put the same question on Forum /Category/Database/Spatial and I have received this reply
    from Brian Camire, this query worked well.
    SELECT
    T.X,
    T.Y
    FROM
    TABLE
    SELECT
    SDO_UTIL.GETVERTICES
    SDO_LRS.PROJECT_PT
    GEOMETRY,
    SDO_GEOMETRY
    3301,
    NULL,
    NULL,
    SDO_ELEM_INFO_ARRAY(1, 1, 1),
    SDO_ORDINATE_ARRAY(580093.859, 4998493.5, NULL)
    FROM
    TABLE_B
    WHERE
    ID_CODE = 970
    ) T;
    Best regards
    Angelo.

  • How to convert oracle spatial to Shapefile ?

    I have download the shp2sdo and convert the shapefile for GIS to Oracle spatial.Now i want to convert it back to shapefile.How do to that?Which feature in Oracle i can do that?
    Hope to get a response.

    There are a lot of other threads that have this discussion, although I can't understand why anyone would want to do such a thing :^)
    Spatial -> Shapefile
    SDO_geometry to ESRI Shapefile
    Re: Export to shapefile (.shp) and .dbf
    and others...
    hope this helps.

  • How to execute a update query when the particular date changes

    hi all,
    i am using date base 11.1.0.6.0,
    i am trying a small update query it should fire when particular date changes in year.
    i think for trigger but i didn't get how to execute it.
    Regards,
    Pavan

    Hi, Pavan,
    Use dbms_scheduler to run a procedure at a given time (or at repeatedly, at given times).
    A trigger is good for re-acting to certain actions in the database, someone INSERTing a row in a given table, for example. Nothing will necessarily be happening when you want your procedure to run, so a trigger is not good in this case.

  • How to acees oracle spatial features

    hi
    i am new to orcale spatial.i want to explore on orcale spatial.for that acessing orcale spatial features hwat are the chnages in setiings.
    and i need exapmles to practice

    Hi,
    Start with the documentation on the Oracle web site. This will depend on the version you plan to explore. Take a look at http://www.oracle.com/database/spatial.html .
    There is also an excellent book which can be got from Amazon http://www.amazon.com/Oracle-Spatial-Database-Experts-Voice/dp/1590598997/ref=sr_1_1?ie=UTF8&s=books&qid=1231752852&sr=1-1
    Happy exploring.
    Ivan

Maybe you are looking for