Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> PL/SQL
I need help with the following:
Part1: I am trying to develop a PL/SQL Package stored within a database to
accept input data for single distance calculations. i need to write a
procedure that will accept two sets of x and y coordinates as input. The
procedure will then output the distance between the points in km. Can anyone
help as I am new to PL/SQL?
The distance between two points (in two-dimensional world) is
SQRT(POWER(x2 - x1,2) + POWER(y2 - y1,2)).
Part2: I am trying to develop a PL/SQL Procedure for multiple distance
calculatons which will take input from a single database table and output
results to another database table. The input and output tables must be
specified as part of the procedure call. The procedure must calculate
distances between all locations specified in the input table and will allow
the user to specify the calculation of distances in both directions if
required. So for 10 locations in the input table, this will result in 100
distance calculations or 50 calculations if only one direction is required.
The procedure will accept as input a flag to indicate whether or not
distances are to be calculated in one direction only or in both directions
from one point to another. The return flag will accept 'Y' or 'N' as its
values.
The table names are 'Location' and 'Dist'
Location Table (Input Table)
Id_number
Region
Name
Code
X
Y
Done
Dist Table (Output table)
From_id
To_id
Distance
Part3:
For multiple distance calculations a second procedure must be developed to
alow the use of 2 input tables. This procedure will calculate distances
between all the records in table 1 and the records in table 2 i.e. it will
calculate distances between location 1 in table 1 and all the locations in
table 2 , then between location 2 in table 1 and all the locations in table
2, then between location 3 in table 1 and all the locations in table 2 and
so. Again this procedure will output results to a database table. The format
of this procedure call might be: Procedure_call (input_table1, input_table2,
output_table).
Please reply to--
paul.kolbohm_at_mallontechnology.com
Received on Thu Feb 22 2001 - 11:16:30 CST
![]() |
![]() |