Identify which set of coordinates is within a radius in the ORACLE base

Asked

Viewed 56 times

1

Hello personal I have a script here in Mysql, however I need to apply it in an Oracle database,

SELECT *,(RAIO_TERRESTRE * 
    acos(
     cos(radians(PARAMETRO_LATITUDE)) * 
     cos(radians(COLUNA_LATITUDE)) * 
     cos(radians(PARAMETRO_LONGITUDE) - radians(COLUNA_LONGITUDE)) + 
     sin(radians(PARAMETRO_LATITUDE)) * 
     sin(radians(COLUNA_LATITUDE))
  )) AS CAMPOLATITUDE
FROM TABELA HAVING CAMPOLATITUDE <= KM

EXAMPLE:

SELECT *, (6371 *
        acos(
            cos(radians(-19.83996)) *
            cos(radians(lat)) *
            cos(radians(-43.94910) - radians(lng)) +
            sin(radians(-19.83996)) *
            sin(radians(lat))
        )) AS distance
FROM tabela HAVING distance <= 5

what this script does and the following:

I have an ORACLE database with latitude (lat) and longitude (lng) coordinates and am passing the one reference point (in the example the values -19.83996 and 43.94910). With this I get all the places that are at a distance of 5 Km from the reference point. However this script is in Mysql and I tried to apply it in Oracle but it presents errors.

  • "but presents errors" , error that , syntax , calculation , etc , the 2nd script is from Oracle ?

  • has already researched whether functions are equal in oracle? cos, sin, radians?

  • No, this script is from Mysql and I need to apply it to Oracle.

  • @Motta when running the script in oracle displays this error "ORA-00904: "RADIANS": invalid identifier 00904. 00000 - "%s: invalid Identifier" *Cause: *Action: Line error: 6 Column: 17"

  • https://www.databasedevelop.com/article/10310157/RADIANS+and+DEGREES https://matika.com.br/radianos/conversao-de-radianos-para-graus

  • It seems that this Function has been discontinued.

  • @MOTTA but and a mathematical operator, they can not discontinue so, may have changed the way of application, but discontinue I doubt

  • I say this because I found a doc of this Function < https://docs.oracle.com/javadb/10.8.3.0/ref/rreffuncradians.html > I really did not search but deep , but I believe that the solution in this case is simple , create a user Function.

  • For and, already tried everything, the fastest solution I found was to generate a file. txt with the coordinates data and import it into a Mysql database I really didn’t want to do this due to take too much time ,I wanted the system to give me the data straight from the Oracle flock. but that was the fastest way I found, hopefully someday solve this script.

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.