How to use function call in SQL statement 
Author Message
 How to use function call in SQL statement

Hello -
I am trying to generate a query that returns data points that are in a
certain proximity to a given global location.  I am using a VB application
to access a MS Access database with global locations mapped by latitude and
longitude.  I also have a function that calculates the distance between two
latitude and longitudes.  Is there a way to incorporate this distance
calculation function into a SQL statement to the database such that it
returns only those locations that meet a certain distance criteria?

For example:

I have point X that has a given latitude and longitude.  I want to write a
query that returns the distance TO each point in the database FROM point X
using my distance calculation function.  Any ideas?

Thanks in advance all!

Regards,
AB



Fri, 23 Jan 2004 07:34:21 GMT  
 How to use function call in SQL statement

Quote:

> Hello -
> I am trying to generate a query that returns data points that are in a
> certain proximity to a given global location.  I am using a VB application
> to access a MS Access database with global locations mapped by latitude and
> longitude.  I also have a function that calculates the distance between two
> latitude and longitudes.  Is there a way to incorporate this distance
> calculation function into a SQL statement to the database such that it
> returns only those locations that meet a certain distance criteria?

> For example:

> I have point X that has a given latitude and longitude.  I want to write a
> query that returns the distance TO each point in the database FROM point X
> using my distance calculation function.  Any ideas?

Not unless you can cram the logic into the SQL statement.  If you're
using DAO, you can use IIf, Choose, Switch, Log, Sqr, etc. in the SQL.
How are the coordinates actually stored?  I suppose if you wanted all
points within, say, 100 km of X, you could calculate what 100 km means
in terms of latitudes and longitudes around X and use the SQL BETWEEN
operator to get everything within a 40 000 km^2 square centered on X
in such a way that will let Jet/Rushmore use indexes for speed.

--

WARNING: I cannot be held responsible for the above        They're   coming  to
because  my cats have  apparently  learned to type.        take me away, ha ha!



Sat, 24 Jan 2004 13:38:29 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Calling function within SQL statement

2. Function Calls within SQL statement

3. Function call within SQL statement

4. Using a query/SQL statement as a function

5. Unable to modify SQL statement using string functions

6. SQL-statement using Date-function?

7. Using Functions in SQL Statement

8. Using a Function within an SQL-Statement

9. Calling a sub or function using a variable through another sub or function

10. Sql statement calling 2 access97 queries in asp page

11. Calling an SQL statement

12. Dynamic SQL statements with OpenRecordSet function

 

 
Powered by phpBB® Forum Software