ORACLE 自定义函数实例
CREATE OR REPLACE FUNCTION GetGEODistance(
bw1 IN NUMBER, dj1 IN NUMBER,
bw2 IN NUMBER, dj2 IN NUMBER) RETURN NUMBER
AS
n_size NUMBER;
BEGIN
SELECT ACOS(cos(abs(dj1-dj2)/180*3.141592653)*cos(abs(bw1-bw2)/180*3.141592653))*6371 INTO n_size
FROM dual;
RETURN n_size;
EXCEPTION
WHEN NO_DATA_FOUND THEN
RETURN 0;
END;